MongoDb
1.-----------------What is NoSQL ?
2.----------------What is MongoDB?
3.----------------MongoDB CRUD Operations
4.---------------MongDB Index Research
5.---------------MongoDB Sharding Research
What is NoSQL?
NoSQL (NoSQL = Not Only SQL), meaning "not just SQL".
Why use NoSQL?
In the modern computing system on the network every day will have a huge amount of data. A large part of these data is handled by the relational database management system (RDMBSs) like Oracle,Mysql SqlServer and so on. Through the application practice proved that the relationship model is very suitable for customer server programming, far beyond the expected benefits, today it is the dominant technology in structured data storage ,network and business applications .
Today we can easily access and crawl mass data through third-party platforms (eg Google, Facebook, etc.). User's personal information, social networks, geography, user-generated data, and user-operated logs have multiplied. If we want to dig these user data, that SQL database is not suitable for these applications, while the NoSQL database is able to deal with these large data.
MongoDB[1] 是一个基于分布式文件存储的数据库。由C++语言编写。旨在为WEB应用提供可扩展的高性能数据存储解决方案。
MongoDB 将数据存储为一个文档,数据结构由键值(key=>value)对组成。类似于json的bson组成---二进制形式的json,MongoDB 文档类似于 JSON 对象 。因此可以存储比较复杂的数据类型。字段值可以包含其他文档,数组及文档数组。
在mongodb中基本的概念是文档、集合、数据库,下面我们挨个介绍
我们可以对比sql和mongodb来了解一下,在关系型数据库中数据库下的基本单位是table,而在mongodb中是用collection,一行数据对应的是mongodv中的一个文档,这就是为司马我们称mongodb为面向文档的数据库,我们注意到mongodb中不存在表连接的情况,关系型数据库的典型特征是表之间存在关联关系,mongodb不存在这种表连接语句,那么文档之间的一对一地以对多,多对多的情况mongodb可以通过在字段中嵌套一个或多个文档来实现这种关系,我认为这是一种以空间换时间的做法,比如有两张表用户表和商品表,一个用户对应多个商品,假设想要查询一个用户下的所有商品信息,在关系型数据库的查询中需要链表查询join,我们知道join必然会带来很多磁盘随机度的操作,随机读无法像顺序读那样的局部性好,缓存效果不好,反观Mongodb这种Nosql系统中,可以将一个用户的对应的所有商品信息嵌套存入该用户对应的文档的字段里面去,也就是说这些信息都cunxz也就是说这些信息都存在一个文档中,局部性很好,这样的虽然磁盘冗余了大量的数据,但却大大加快了查询的速度,从当前计算机的发展来看,空间hua空间换时间是很正常的,而计算机最关键的技术高速缓存cache技术就是用空间huansh技术就是用空间换时间的典范。
想到这里其实也给了我一些提示,比如很多人在使用Mysql的过程中查询记录过多,比如2000W条数据的时候,数据库性能就开始下降,Nosql给我们的提示就是可以通过宽表冗余一些数据来实现join,这就是一种空间换时间的做法。
最后更新:2017-08-13 22:22:58