Data Model Examples and Patterns
MongoDB 5.0 is end of life as of October 2024. This version of the documentation is no longer
supported. To upgrade your 5.0 deployment, see the MongoDB 6.0 upgrade procedures.
The following documents provide overviews of various data modeling patterns and common schema design considerations:
- Model Relationships Between Documents
Examples for modeling relationships between documents.
- Model One-to-One Relationships with Embedded Documents
- Presents a data model that uses embedded documents to describe one-to-one relationships between connected data.
- Model One-to-Many Relationships with Embedded Documents
- Presents a data model that uses embedded documents to describe one-to-many relationships between connected data.
- Model One-to-Many Relationships with Document References
- Presents a data model that uses references to describe one-to-many relationships between documents.
- Model Tree Structures
Examples for modeling tree structures.
- Model Tree Structures with Parent References
- Presents a data model that organizes documents in a tree-like structure by storing references to "parent" nodes in "child" nodes.
- Model Tree Structures with Child References
- Presents a data model that organizes documents in a tree-like structure by storing references to "child" nodes in "parent" nodes.
See Model Tree Structures for additional examples of data models for tree structures.
- Model Specific Application Contexts
Examples for models for specific application contexts.
- Model Data for Atomic Operations
- Illustrates how embedding fields related to an atomic update within the same document ensures that the fields are in sync.
- Model Data to Support Keyword Search
- Describes one method for supporting keyword search by storing keywords in an array in the same document as the text field. Combined with a multi-key index, this pattern can support application's keyword search operations.