Why it matters
A relational schema is normalised first and indexed for queries later; a NoSQL store usually inverts that, because the physical layout follows the access pattern and changing the pattern means rewriting the data. That is a good trade when the pattern is known and the volume is high, and a bad one when the product is still discovering what it needs to ask. The choice has to be made with the query set in view.
Mental model
It is a filing cabinet organised by the question you expect to ask: fast for that question, expensive for any other. The analogy breaks because a record can be duplicated into several cabinets, which keeps every question fast and makes every update a multi-place write.
How it works
- 1Write the access patterns first: the exact queries, their frequency and their latency targets.
- 2Choose the model from those patterns, then decide the partition key so reads and writes spread evenly.
- 3Decide where duplication is acceptable, and list every place a single fact is stored.
- 4Set consistency per operation, and test the behaviour when a read follows a write immediately.
- 5Check index limits and whether secondary indexes are updated synchronously.
- 6Plan the migration path, because changing the partition key requires rewriting the data set.
Step 1 of 6
Write the access patterns first: the exact queries, their frequency and their latency targets.
Figure. The mechanism in this page's own steps. The figure adds sequence, not new claims.
What to notice. A step can be read alone, but the order is the mechanism. The control lets you stop on any one.
Text version
The page's steps: 1. Write the access patterns first: the exact queries, their frequency and their latency tar… 2. Choose the model from those patterns, then decide the partition key so reads and writes s… 3. Decide where duplication is acceptable, and list every place a single fact is stored. 4. Set consistency per operation, and test the behaviour when a read follows a write immedia… 5. Check index limits and whether secondary indexes are updated synchronously. 6. Plan the migration path, because changing the partition key requires rewriting the data s…
- Write the access patterns first: the exact queries, their frequency and their latency targets.
- Choose the model from those patterns, then decide the partition key so reads and writes spread evenly.
- Decide where duplication is acceptable, and list every place a single fact is stored.
- Set consistency per operation, and test the behaviour when a read follows a write immediately.
- Check index limits and whether secondary indexes are updated synchronously.
- Plan the migration path, because changing the partition key requires rewriting the data set.
Trade-offs
| Choice | Good for | Cost | Fails when |
|---|---|---|---|
| Document store | Flexible shape per record | Cross-document joins are expensive | Queries span many entity types |
| Key-value store | Very low latency at scale | No query language beyond the key | The access pattern changes |
| Wide-column store | High write throughput on large data | Rigid schema and query planning | The team needs ad-hoc queries |
| Graph database | Traversal-heavy relationships | Smaller ecosystem and operational familiarity | The workload is mostly key lookups |
Good for
Flexible shape per record
Cost
Cross-document joins are expensive
Fails when
Queries span many entity types
- Queries span many entity types
- The access pattern changes
- The team needs ad-hoc queries
- The workload is mostly key lookups
Figure. Each choice with what it buys, what it costs, and the case where it loses.
What to notice. The fourth column is the decision: if the losing case describes your situation, the choice is wrong.
Text version
Four trade-offs: Document store is good for Flexible shape per record, costs Cross-document joins are expensive, and fails when Queries span many entity types. Key-value store is good for Very low latency at scale, costs No query language beyond the key, and fails when The access pattern changes. Wide-column store is good for High write throughput on large data, costs Rigid schema and query planning, and fails when The team needs ad-hoc queries. Graph database is good for Traversal-heavy relationships, costs Smaller ecosystem and operational familiarity, and fails when The workload is mostly key lookups
Failure modes
- Hot partition. One key receives most traffic and latency spikes while the cluster looks underused. Debug: chart request rate per partition key and look for a single dominant value.
- Read-after-write surprise. A user updates a record and sees the old value on the next request. Debug: reproduce with an immediate read against the same consistency setting and compare replicas.
- Unbounded document growth. A record grows with every event and eventually exceeds the item size limit. Debug: track maximum document size per collection and alert before the limit.
In production
Monitor per-partition throughput, throttling events and replication lag, since these are signals a relational dashboard does not show. Cap document size and index count, and review access patterns before adding a new query path.
Common misconceptions
People think: NoSQL means no schema.
Actually: It means the schema is enforced by the application and by the access pattern, which is usually harder to change than a migration.
People think: Eventually consistent means it will be consistent soon.
Actually: It means there is no bound without a mechanism; the window depends on replication and on how you read.
Interview angle
Start from access patterns, then name the partition key and the duplication cost. Explain that consistency is per operation. Choosing a product by reputation and meeting the query shapes later is the usual mistake.
Sources
- DeCandia et al., Dynamo — partitioning, replication and eventual consistency at scale.
- MongoDB documentation — document modelling and read/write concern settings.
- Kleppmann, Designing Data-Intensive Applications — the consistency and storage trade-offs behind these systems.