How to design a MongoDB Data Model

Source: Internet
Author: User
Tags install mongodb

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:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.