How to design a MongoDB Data Model
Effective data models serve applications. The key issue in the design architecture is whether the document model is applicable to embedded models or references ).
Embedded Data Model (Embedded Data Models)
In MongoDB, you may embed relevant data into a single structure or document. These models are generally called "informal" models, but they fully utilize the MongoDB rich document model.
The embedded data model allows the application to store related information in a database record, so that the application may need less query and update to complete common operations.
Generally, the embedded data model is applicable to the following scenarios:
(1) Having relationships between entities
(2) there is a one-to-many relationship between entities. In these relationships, "documents" or subdocuments always appear in the context of "one" or rich documents.
Generally, Data embedding provides better performance in read operations, allowing you to request and retrieve relevant data in a single data operation. The embedded data model enables MongoDB to update related data in an atomic write operation.
Then, embedding relevant data may cause the document to grow too much after it is created. Document growth affects Data Writing Performance and leads to data sharding. In addition, the document size in MongoDB must be smaller than the maximum document size specified in BSON format (the maximum BSON document size is 16 MB ). For most of the binary data, see GridFS.
Interact with embedded documents and use the "." symbol to enter the embedded document.
Normalized Data Models, References)
The canonicalized Data Model describes the relationship between document references.
The canonicalized data model is applicable to the following scenarios:
(1) When the embedded data model leads to data duplication, and the advantage of the read performance provided by the model will not be duplicate.
(2) present many complex multi-to-many relationships.
(3) Modeling large-scale hierarchical data sets
The References mode provides better flexibility than the embedded mode, but the client application must solve the problem of reference subsequent queries. In other words, the canonicalized data model requires more rounds of request servers.
CentOS compilation and installation of MongoDB
CentOS compilation and installation of php extensions for MongoDB and mongoDB
CentOS 6 install MongoDB and server configuration using yum
Install MongoDB2.4.3 in Ubuntu 13.04
MongoDB beginners must read (both concepts and practices)
MongoDB authoritative Guide (The Definitive Guide) in English [PDF]
MongoDB details: click here
MongoDB: click here
This article permanently updates the link address: