I. A brief introduction of NoSQL
The structured programming provided by RDBMS (relational database) makes data modeling and application programming very simple, with very high economic benefits, and low learning costs. However, in today's data explosion era, every moment will be a huge amount of data generation, the data read and write requirements are more and more high, RDBMS can not meet the needs of people, NoSQL was born.
NoSQL (not only SQL) means: No longer just a structured query, it is completely different from the RDBMS's data storage structure, only to ensure that the final consistency of the data rather than adhere to the acid principle, read and write performance far more than the RDBMS database. is essential in big data storage.
Common NoSQL such as:
1) Redis
2) MongoDB
3) memcached
Ii. introduction of MONGO
MONGO is also a nosql, but unlike Redis, it's somewhere between NoSQL and RDBMS. Written in C + +, is a distributed file storage of open-source database system, with high performance, high availability, easy to expand and other features. The basic data structure is: key-value structure, can analogy JSON data structure to understand MONGO data structure.
Let's take a look at four key concepts:
1) Data Base (database)
As with all database systems, MONGO can also create multiple independent database,database to store data.
2) Set (collection)
We can understand collection,collection stored in database by analogy to the concept of "table" of RDBMS.
3) Documentation (document)
We can understand document,document exists in collection by analogy to the concept of "line" in RDBMS.
4) Domain (field)
We can understand that Field,field exists in document by analogy to the concept of "column" of the RDBMS.
Such as:
Third, the data type
data type |
description |
Td>string
string |
integer |
integer |
Boolean |
Boolean |
double |
double precision |
min/max keys |
set a value and the lowest value of Bson and Highest value comparison |
array |
array or list |
Timestamp |
timestamp |
Object |
for inline documents |
Null |
create null value |
symp OL |
symbol, usually identical to string |
date |
date time |
Object ID |
Object ID |
binary Data |
binary |
Code |
JS script code |
Regular expression |
Regular Expressions |
The above data types specifically mention the object ID, which is similar to a unique primary key that can be quickly generated and sorted, including 12byte:
0-3 bytes is time stamp of GMT (8 hours late in Beijing)
4-6 is the machine identification code
7-8 is the process ID
9-11 is a random number.
The document stored in the MONGO must have a _id key. The value of this key can be any type, but the default is the object ID.
Since Objectid saves the timestamp of the creation by default , you do not need to save the timestamp field for your document, and you can get the timestamp by Gettimestamp. Such as:
var newObject = ObjectId ()> newobject.gettimestamp () isodate ("2017-11-25t07:21:10z")
Iv. Summary
MONGO in C + +, is a distributed file storage open source database, high performance, high availability, easy to expand, the data structure is similar to the structure of JSON, support rich data types.
MongoDB (1) Introduction