What?
One of the most popular non-relational databases. Document-oriented databases are fundamentally different from relational databases in terms of data storage.
Why?
Simple to use
Adaptable to SQL-based DB for changing business needs
Performance
Copy
Index
Sharding
A rich query
Flexible data Model
No less than the speed
Good performance under massive data
Programmer-Friendly, but DBA nightmare, poor maintainability
Constitute
The organizational structure of MongoDB, as opposed to the database row-and-table SQL database, is: Document---collection
The document, collection, approximately corresponds to the concept of a row, table in a SQL-based database.
Document
Documents are sensitive to the order of multiple Key:value: for example:
‘name‘ : ‘tom‘ , ‘age‘: 21 , ‘email‘: ‘[email protected]‘
‘name‘ : ‘tom‘ , ‘email‘: ‘[email protected]‘,‘age‘: 21 }
The above two documents are considered to be two different documents.
A key named for each document is added to _id
the system. This key is a unique identity that the system has for the same colletion
document
.
_id
The value is a special type in MongoDB: ObjectID()
.
MongoDB creates a key for a document when it is stored in the database, unless you specify the value of the attribute in the document _id
.
Key
- Key cannot be duplicated
- The document's key is of type string
- Document is case sensitive to key
- Value
- Values in a document can be of multiple types
- Value can be a document (inline document)
Collection
- Table equivalent to relational database
Collection is modeless: that is, a document of a different structure can belong to the same collection, which cannot be done in a relational database, as you cannot put two rows of different structures into the same table.
OK, since we can put different structure of document into the same collection, why do we need more than one collection?
In fact, we should put the same type of document in a collection, but that does not mean that we have a strong requirement for the structure of the data (document), and MongoDB allows us to manage the data more flexibly. Classifying documents means producing multiple collection that can also increase our access speed and reduce the burden on the server, while also allowing us to better organize and manage the data (MongoDB's DBA is a broken-winged angel for Life).
MongoDB supports a wide variety of data types, the main one being the extensible JSON-type data, summarized below:
- Null
- bool
- Int32
- Int64
- Float64
- String
- Symbol
- ObjectId ()
- Date
- Expressed as the number of milliseconds starting from the era
- Regular expressions
- JavaScript code
- Binary data
- Maximum Value (BSON)
- Minimum value (BSON)
- Undefined
- Array
- Cocument
The following is a basic usage of the shell of MongoDB. To be Continued ...
A preliminary summary of MongoDB Learning