Database Design (SQL vs. NoSQL)
Match your data model and access patterns to SQL, document, key-value, wide-column, or graph stores.
In plain words
Database design is deciding how to organize your data so it is easy to store, find, and keep correct. The first big choice is a SQL (table-based) or a NoSQL database.
Think of it like…
Choosing between a filing cabinet (SQL), labeled folders (Document), numbered safety-deposit boxes (Key-Value), or a subway map (Graph).
Where you’ve seen it
A bank uses SQL tables with strict rules so balances are always correct. A social feed might use NoSQL to store huge amounts of flexible post data quickly.
Words you’ll hear
- Schema
- The blueprint of your data: tables, columns, and their types.
- SQL / relational
- Data in tables with relationships and strong guarantees (e.g. PostgreSQL).
- NoSQL
- Flexible stores such as key-value, document, or wide-column (e.g. DynamoDB, MongoDB).
- ACID
- Guarantees that a transaction fully happens or not at all, and stays correct.
Visual diagram
Theory & deep dive
Start with SQL unless you have a concrete reason not to
Modern relational databases like PostgreSQL handle huge workloads (tens of thousands of QPS, terabytes of data, JSON columns, full-text search, even vector embeddings) while giving you rock-solid ACID transactions and flexible queries.
You move to specialized NoSQL stores when you need massive write throughput across many regions (Cassandra/DynamoDB), millisecond key-value lookups (Redis), or deeply connected social graphs (Neo4j).
Normalization vs. Denormalization
Normalization stores each fact once (e.g., users.name lives only in users, and orders points to user_id), preventing mismatched copies. Denormalization duplicates author_name directly inside each post document so reading a feed needs zero JOINs.
High-scale systems frequently normalize the source-of-truth database and denormalize into read caches or search indexes.
How it works, step by step
Step 1 of 41. Map your core entities and query patterns
Write down every read/write query before picking a database. Ask: Do we need multi-row ACID transactions, flexible schemas, or massive write throughput?
- ACID Required?
- Orders, ledgers
- Write Volume
- QPS & row growth
When to use it & trade-offs
What it is
Database design means choosing the right storage family and schema (normalization vs. denormalization) based on consistency needs, query shapes, and write/read scale.
Why it matters: Picking the wrong database forces painful application workarounds - like doing multi-table joins in DynamoDB or storing unstructured time-series streams in PostgreSQL without partitioning.
When to reach for it
- Relational SQL for financial balances, inventory locks, and relational SaaS data
- Wide-column/Key-value for trillions of events, IoT telemetry, or global session stores
- Time-series DBs (Timescale, InfluxDB) for high-ingest metrics and downsampling
When to avoid or be careful
- Choosing NoSQL “for scale” when your workload fits easily on one SQL instance and needs joins
- Duplicating authoritative truth across two databases without Change Data Capture (CDC)
Database Families Compared
Strengths: Strong ACID guarantees, ad-hoc SQL joins, mature tooling & constraints.
Watch out: Horizontal write sharding is operationally harder than single-node scaling.
Strengths: Linear horizontal scaling via partition keys; predictable single-digit-ms reads.
Watch out: No ad-hoc joins; must design partition & sort keys upfront.
Strengths: Natural mapping to nested objects (Doc) or traversals (Graph).
Watch out: Cross-document joins (Doc) or horizontal sharding (Graph) can be costly.
Interview signals & numbers to know
When this topic comes up
- ACID transactions
- double booking
- unstructured schema
- write-heavy telemetry
- social graph
Benchmarks & rules of thumb
- Well-tuned Postgres
- 10k–50k+ read QPS
- DynamoDB single-key read
- ~1–5 ms
- Max row/item size (DynamoDB)
- 400 KB
- Graph DB sweet spot
- Queries with 3+ relationship hops
Common mistakes & follow-ups
Common interview mistakes
- Forgetting to define the partition key and sort key when choosing DynamoDB/Cassandra
- Trying to enforce strict financial invariants across eventually consistent NoSQL tables
- Using a single giant JSON column in SQL for fields you constantly filter and index
Likely interviewer follow-ups
- When would you denormalize data inside PostgreSQL vs. migrating to DynamoDB?
- How do you keep OpenSearch or Redis consistent with PostgreSQL writes (Outbox + CDC)?
- Why does Cassandra excel at write-heavy workloads compared to B-tree databases?
Knowledge check
Put it into practice
Design full architectures with AI feedback
Apply Database Design (SQL vs. NoSQL) inside real High-Level Design prompts or review Q&A flashcards.