Document DB Data Modeling (Embedding vs Referencing)
Master NoSQL document modeling in MongoDB: Embedded Documents (Denormalized 1:1, 1:Few) vs Normalized References (1:Many, 1:Squillions, M:N), and the 16MB BSON limit.
01.1. The Golden Rule of Document Modeling
In relational databases, data is designed around entities and normalized to 3NF. In document databases (MongoDB, Couchbase), data is modeled around application access patterns:
The Core Document Modeling Principle: "Data that is accessed together should be stored together!"
When designing schemas in MongoDB, developers face a binary architectural choice for every relationship:
- Embedding (Denormalization): Nest child documents directly inside the parent document as nested objects or arrays.
- Referencing (Normalization): Store entities in separate collections, linking them using
ObjectIdreferences (similar to Foreign Keys), resolving links via application-level queries or MongoDB$lookupaggregation pipelines.
Document DB Data Modeling: Embedding vs Referencing Decision Tree π³
Document DB Data Modeling: Embedding vs Referencing Decision Tree π³
When to embed subdocuments (1:1, 1:Few for single-read performance) vs when to normalize with references (1:Many, 1:Squillions, M:N to avoid 16MB BSON limits).
Unlock Topic #52: Document DB Data Modeling (Embedding vs Referencing)
You are viewing a preview. The full in-depth engineering deep dive, interactive simulators, architecture flowcharts, and self-assessment quizzes for this topic are available with Pro or Lifetime Access.
Failure modes, high-throughput bottlenecks, and real FAANG implementation decisions.
Interactive system topology diagrams, live parameter simulators, and downloadable SVG charts.
Staff-level multiple-choice quiz questions with instant feedback and answer explanations.
Firebase Google authentication automatically syncs your completed topics and quiz scores.
How clear and staff-actionable was this system breakdown?