MongoDB data is particularly flexible. Compared with SQL databases, it does not need to define the table structure before inserting data. MongoDB collections do not emphasize fixed document structures. This flexibility
MongoDB data is particularly flexible. Compared with SQL databases, it does not need to define the table structure before inserting data. MongoDB collections do not emphasize fixed document structures. This flexibility
MongoDB data is particularly flexible. Compared with SQL databases, it does not need to define the table structure before inserting data. MongoDB collections do not emphasize fixed document structures. This flexibility allows it to easily map the document structure. Each document can map objects to be expressed, even if the data is substantially different. In practice, documents in the same set usually adopt similar structures.
The main problems of MongoDB data modeling are the application requirements, the performance characteristics of the database engine and the data retrieval model. To design a data model, you always need to consider the data used by the application (query, update, and data to be processed) and the data structure itself.
Document Structure
The key to designing the MongoDB data model is to consider the relationship between the document structure and the data represented by the application. There are two ways to express this relationship: references and embedded documents ).
References)
References stores the relationships between data, including links from a document or References to another document. In this way, the application solves the problem of accessing associated data. Generally, these are data models that regulate data.
Embedded Data
Embedded documents capture the relationship between data by storing relevant data in a document structure. MongoDB documents can be embedded in fields or arrays of the current document as sub-documents. These nonstandard data models allow applications to retrieve and operate data related to operations in a single database.
Atomicity of write operations
In MongoDB, write operations are atomic at the document level. No write operation can automatically affect multiple documents or collections. The standardized embedded data model integrates all associated data to present entities in one document. This helps atomic write operations insert and update object data in a write operation. Standardized data can separate data from multiple sets and requires multiple write operations in non-atomic operations.
Then, the mode that promotes atomic writing may restrict the use of data by applications, or restrict the method for modifying applications. Atomicity considers the challenges of design patterns and balances flexibility and atomicity.
Document added
Updates such as adding elements to an array or adding new fields will increase the document size. If the document size exceeds the size of the file, MongoDB will re-allocate disk space. Considering the increase in space, standard data should be normalized or used.
Data Usage and Performance
When designing a data model, you should consider how the application uses the database. For example, if the application only uses the recently inserted document, consider using the top collection (Capped Collections ). If the application needs to read the set frequently, adding an index can improve the data query efficiency.
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