In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
One-to-one relationship: Embed, for example, the user information collection has an Address field, and the Address field has three fields: province, city and county. The model is as follows:
One-to-many relationship: there are many comments in an article, which is an one-to-many relationship
Because MongoDB has a size limit of 16m (higher than v1.8) for a single document (document), this limitation should also be taken into account at design time.
Many-to-many relationship: there is a many-to-many relationship between students and courses. A student can take multiple courses and multiple students participate in one course.
Many-to-many uses Linking, which connects two collections through References. There are two types of MongoDB References: one is 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 information of an article, first find the article in the post collection, and then find all the information about the user in the user collection. But if there is such a scene: users can comment on pictures, articles and other resources, and all the comments are placed in the comment collection, if you just use Manual References, it is not clear what kind of resources comments belong to, pictures? Article? So there's DBRef.
The form of DBRef:
{$ref:, $id:, $db:}
$ref: collection name; $id: referenced id;$db: database name, optional parameter.
You can see that the structure of DBRef is more complex than that of Manual References, which takes up more space, but it is also powerful. If you want to connect across databases, the examples of comments collection mentioned above need to use the functions provided by DBRef,MongoDB to parse DBRef, instead of having to manually write queries twice like Manual References.
The official website of MongoDB for data modeling of MongoDB also gives some suggestions. These suggestions all provide some references. The actual modeling needs to be analyzed according to specific requirements, and what operations (sorting, finding, modifying) are often performed by the analysis data to select Embed and Link.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.