When to choose a relational database vs a document, key-value, or wide-column store.
Published April 7, 2025
Choosing the right database is a system design interview staple. There is no universal winner — the right choice depends on your data model, access patterns, and consistency requirements.
Examples: PostgreSQL, MySQL, SQLite, Oracle
Strengths:
Weaknesses:
// Embed related data in one document — no JOINs needed
{
"_id": "user_123",
"name": "Alice",
"orders": [
{ "id": "ord_1", "total": 99.99, "items": [...] },
{ "id": "ord_2", "total": 49.00, "items": [...] }
]
}
Best for: content management, user profiles, catalogs, event data.
Ultra-fast O(1) reads/writes. Best for: caching, sessions, leaderboards, rate limiting.
Distributed, high-write throughput. Best for: time-series, IoT telemetry, activity feeds.
First-class relationships. Best for: social networks, fraud detection, recommendations.
| Question | Lean SQL | Lean NoSQL |
|---|---|---|
| Complex relationships? | Yes | No |
| Need JOINs? | Yes | No |
| Schema stability? | Stable | Evolving |
| Write volume? | Moderate | Very high |
| Horizontal scale? | Hard | Easy |
| ACID across entities? | Yes | No (usually) |
SQL databases typically prioritise Consistency + Availability (CA) — they work well in a single data centre with synchronous replication.
NoSQL databases often prioritise Availability + Partition Tolerance (AP) — they trade strong consistency for horizontal scale and fault tolerance.