NoSQL data modeling fundamentally differs from relational design by prioritizing query patterns and access patterns over normalized table structures, embracing denormalization, and embedding related data together. While relational databases optimize for storage efficiency and referential integrity, NoSQL databases optimize for read performance, horizontal scalability, and flexible schemas that evolve with application needs. The key insight: in NoSQL, you model for how you read the data, not how you store it—document boundaries should align with what the application fetches together, and duplication is a feature, not a bug, when it eliminates expensive joins or cross-partition queries.
What This Cheat Sheet Covers
This topic spans 12 focused tables and 59 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
Table 1: Document Model Foundation Patterns
| Pattern | Example | Description |
|---|---|---|
{user: "alice", address: {city: "NYC", zip: 10001}} | Store related data together in a single document for atomic reads and writes; ideal when data is read together and relationship is one-to-few or contained. | |
{user: "alice", order_ids: [101, 102]}{_id: 101, items: [...]} | Store references (IDs) to related documents in separate collections; use when relationship is one-to-many with high cardinality, data is updated independently, or embedding would create unbounded growth. | |
{post: "...", comments: [{text: "...", by: "user1"}, {...}]} | Embed small arrays (typically < 100 items) directly in parent document; bounded relationship where children are rarely accessed independently. |