Schema design as workload-driven design
coreintermediateA MongoDB schema is designed around how the app reads and writes data, not around normalizing entities. The same real-world data can be modeled two very different ways depending on the workload.
Think of it as
A relational schema asks "what are the entities and their relationships," then normalizes to avoid duplication, and the query layer is expected to adapt via joins. MongoDB flips the order: ask "what will the application actually query, and how often," then shape documents so the common queries are cheap — even if that means the same data appears in more than one place. The schema is downstream of the workload, not the other way around.
What we're doing: Show the same two entities (a blog post and its comments) modeled two different ways for two different workloads.
- 2
- Workload A embeds comments because they are always read with the post — one query gets everything.
- 5
- Workload B references comments in their own collection because they are queried and moderated independently of any one post.
Why this works: Neither shape is "more correct" in the abstract — a relational-thinking reviewer might flag the embedded version as denormalized, but it is the right choice if workload A is real. The schema is a means to a performance end, not a modeling exercise judged on its own terms.
Modeling entities and relationships first, then asking how to query them
Wrong
Better
What you see: The schema looks clean and normalized, but common pages require several sequential queries or application-side joins to assemble one response.
Why: A schema built to mirror entities, without first asking what the application actually queries, tends to need $lookup or client-side joins for every common read — the exact cost MongoDB's document model exists to avoid.
- access patterns — what gets queried, how often
- schema shape — documents, embedding, indexes
- performance — the point of the exercise
Remember: Design the schema around the application's actual read/write patterns first — not around normalized entities the way a relational schema would be.
See also: access patterns not entities · workload types

