How mongodb Designs schema

  mongodb, question

We all know mongodb is a document-oriented database, but its flexibility doesn’t mean that you don’t need to carry out structural design. It is very necessary to carry out structural design before code implementation.

However, the problem arises. Almost all the database design tools we use at present cannot show mongodb as a document-oriented data structure. So how can we clearly show our structure to others when we do design? I don’t want to use ps to remove picture frames one by one.

In fact, this design philosophy of the official website is very good (http://www.mongodb.org/display/DOCS/S …)
The biggest difference between MongoDB and traditional SQL schema design is about which method is better to express the model relationship (Link and Embedded can be used in MongoDB)

To summarize briefly:

  1. FirstClass (such as “User”) should use a separate Collection
  2. “Item type”, should be embedded
  3. If the two models are inclusive, embedded is used
  4. Many-to-many relation, using link (similar to the foregin key in sql)
  5. If a model may have few objects, then use a separate collection, which helps mongodb server to do caching.
  6. Embedded mode is not conducive to making complex association and complex query.
  7. Embedded mode has great performance advantages. if you have “performance” requirements, you can consider using embedded mode.