A newer version of this documentation is available.

View Latest

Entity Relationships and Document Design

Logical data modeling starts with a decision on how to map your entities to documents. JSON documents provide great flexibility in mapping 1-to-1, 1-to-many or many-to-many relationships.

At one end, you can model each entity to its own document with references to represent relationships. At the other end, you can embed all related entities into a single large document. However, the right design for your application usually lies somewhere in between. Exactly how you should balance these alternatives depends on the access patterns and requirements of your application. The following sections present a detailed discussion of tools for representing relationships and best practices for each type of relationships.

It is important to note that binary key-value data is better suited for modeling long, narrow and mostly uniform data. For example, temperature measurements from an instrument that is repeated every few seconds. However, as the sophistication of the entities, attributes and relationships increases (larger number of attributes per entity, multilevel, cascading relationships, and more) the benefits of JSON documents become much more significant.