O'Reilly logo

MongoDB Data Modeling by Wilson da Rocha França

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Common document patterns

Now that we understood the way we can design our documents, let's take some examples of real-life problems, such as how to write a data model that better describes the relationship between entities.

This section will present you with patterns that illustrate when to embed or when to reference documents. Until now, we have considered as a deciding factor:

  • Whether consistency is the priority
  • Whether read is the priority
  • Whether write is the priority
  • What update queries we will make
  • Document growth

One-to-one

One-to-one relationships are simpler than the others. Most of the time, we will map this relationship with embedded documents, especially if it is a "contains" relationship.

The following example shows a customer's document. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required