MongoDB Data Modeling Notes
A document-database mental model for aggregates, embedding, references, indexes, and operational tradeoffs.
- Status
- evergreen
- Visibility
- public
- Category
- Databases
- Difficulty
- intermediate
- Published
- Jun 28, 2026
- Updated
- Jun 28, 2026
Mental Model
MongoDB works best when documents represent natural aggregates that are usually read and written together. The unit of design is not a table row; it is the shape of the application access pattern.
Embed When
- Child data is bounded.
- Parent and child are read together.
- Updates usually touch the same aggregate.
- Strong locality is more useful than independent querying.
Reference When
- Child data grows without bound.
- Many parents share the same entity.
- Independent lifecycle or permissions matter.
- The query path naturally starts from either side.
Indexes
Indexes should match real filters and sort orders. A flexible schema does not remove the need for deliberate query design.
Design Smells
- Giant documents that grow forever.
- Collections with no clear aggregate boundary.
- Cross-collection joins simulated repeatedly in application code.
- No plan for schema evolution.
- No clarity around consistency expectations.
Source Links
Related Notes
MongoDB Data Modeling Checklist
A checklist for deciding when to embed, reference, index, and evolve MongoDB documents.
Database Design Mental Models
A durable set of data modeling questions for relational and document databases.
Database Design Checklist
A checklist for choosing and shaping relational or document data models.
PostgreSQL Production Notes
Operational Postgres concepts for backend engineers: schemas, indexes, transactions, migrations, and reliability.
PostgreSQL Production Checklist
A compact checklist for Postgres-backed backend services.
Backlinks
MongoDB Data Modeling Checklist
A checklist for deciding when to embed, reference, index, and evolve MongoDB documents.
Database Design Mental Models
A durable set of data modeling questions for relational and document databases.