NoSQL tradeoffs
Redis data structures, MongoDB documents, DynamoDB partition-key design and hot partitions. Choose by access pattern and consistency need — never by fashion.
The mental model
A relational database is a general-purpose filing system: you store data once in normalised tables and answer any question you can dream up later with joins and ad-hoc queries. NoSQL stores are the opposite bet — each is a specialised tool shaped around one access pattern, and it is spectacular at that pattern and often terrible at everything else. Redis is a Swiss Army knife of in-memory data structures optimised for microsecond access. MongoDB stores whole documents you fetch and update as a unit. DynamoDB is a hash table the size of the internet, brilliant at "give me the item with this key" and hostile to "scan everything where X".
The mental shift: with SQL you model the *data* and figure out queries later; with NoSQL you model the *queries* and shape the data to serve them. You decide your access patterns up front — "fetch a user's last 20 orders by user id", "increment a view counter", "get the session for this token" — and design the store around exactly those. Get the access pattern wrong and there is no CREATE INDEX to save you; you re-model and re-migrate.
Why this exists — what breaks without it. A relational database on one primary has a throughput ceiling and every query competes for the same machine. When you need a million counter increments a second, or single-digit-millisecond reads at any scale, or a data shape that is genuinely a nested document with no fixed schema, SQL fights you. But the reverse failure is more common and more expensive: teams reach for MongoDB because it is "web scale" or "schemaless", model it like they would model tables, then discover they need a join it cannot do, a transaction across documents it makes awkward, or an aggregation that scans the whole collection. The cardinal sin is choosing NoSQL by fashion instead of by access pattern, and interviewers probe for exactly that — every "we used Kafka/Mongo/Dynamo" answer earns a "what problem needed it?"
- Deep dive
- Internal architecture
- Real-world use cases
- Best practices
- Common mistakes
- Performance
- Security
- Production troubleshooting
- Advantages & disadvantages
- Alternatives
- Interview expectations
- Interview questions
- Facts to remember
- Cheat sheet
- Quick revision