KeywordsData modeling courses articles if more off
One-to-one relationship: Embed, such as http://www.aliyun.com/zixun/aggregation/10619.html "> User information collection has Address field, Address field has three fields of province, city, county. Modeling is as follows:
One-to-many Relationship: An article has multiple comments, for 1 to many relationships
Because MongoDB has a size limit of 16M (higher than v1.8) for a single document, it is designed to take this restriction into account.
Multi-many-to-many Relationship: Students and courses are a many-to-many relationship, one student can choose a number of courses, a course with a number of students involved.
Many-to-many uses a connection (linking), which connects two sets by reference (References). There are two kinds of MongoDB References: one is manual reference (Manual References) and the other is dbrefs.
Manual References:
(User collection)
(Post collection)
The red box is manual References, if you want to query the author of an article, first find the article in the Post collection, and then look up all the information in the user collection. But if there is such a scene: Users can be on the pictures, articles and other resources comments, all the comments are placed in the comment collection, if only the use of manual References, it is not clear what kind of resources are the comments, the picture? Article? So with Dbref.
Can see DBREF structure than manual references complex, occupy a large space, but also powerful, if you want to cross the database connection, the above comments set of examples, all need to use the DBREF,MONGODB provides a function to parse dbref, Not like manual references need to manually write two queries.
About MongoDB Data Modeling MongoDB website also gives some suggestions. These recommendations provide some reference, the actual modeling needs to be based on specific requirements analysis, analysis of the data will often perform what operations (sorting, lookup, modification) to select Embed and link.
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.