MongoDB (quad) MongoDB data Model

Source: Internet
Author: User

The data in MongoDB has a flexible pattern. Documents in the same set are not required to have a collection of common fields of the same set of fields or structures, and the document can accommodate different types of data.

Some considerations for MongoDB design Patterns
    • The architecture can be designed according to user requirements.

    • Merges the object into a file if you want to put them together. Otherwise separate them (but make sure you don't need to connect).

    • Duplicate data (limited) because disk space is cheap (compared to compute time).

    • You do not need a connection to write, but read.

    • Optimizing the schema is the most common use case.

    • Do complex aggregation on the pattern.

Example

Suppose a client needs a database design, design a blog site, and look at the differences between RDBMS and MongoDB architecture design. The website has the following requirements.

    • Each article content has a unique title, description and URL.

    • Each article content can have one or more tags.

    • Each article content has its own number of publishers like the name.

    • Each article content has comments as well as names, messages, time and favorite users.

    • For each article, it can be 0 or more comments.

The above requirements are designed in RDBMS mode and there will be at least three tables.

The MongoDB pattern design is a collection of articles and has the following structure:

{   _id:post_id   title:title_of_post,    description:post_description,   by:post_by,   url:url_ Of_post,   Tags: [TAG1, TAG2, TAG3],   likes:total_likes,    comments: [          {         User:' comment_by ' ,         Message:text,         datecreated:date_time,         like:likes       },      {         User:' Comment_ By ',         message:text,         datecreated:date_time,         like:likes      }   ]}

Therefore, although the RDBMS wants to display data, it needs to add three tables, while the MongoDB data is only from a collection.

MongoDB (quad) MongoDB data Model

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.