Interview's MateSystem Design
Interview's Mate

System Design

Architecture & trade-offs

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
System Design topics
Lesson 8/ 31
Storage, Caching & Search

Database Design (SQL vs. NoSQL)

Match your data model and access patterns to SQL, document, key-value, wide-column, or graph stores.

BeginnerSQL · NoSQL · Access Patterns3 quiz questions0/2 subtopics done
Practice in AI HLD
In plain wordsDiagramTheorySubtopics (2)Step by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice
Deep-dive subtopics (2) - 0/2 completed
SQL vs. NoSQL Decision Guide

Know which database family fits transactional, document, wide-column, time-series, and graph workloads.

Beginner
ACID Transactions vs. BASE

Understand Atomicity, Consistency, Isolation, Durability versus Basically Available, Soft state, Eventual consistency.

Intermediate

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

Loading interactive diagram
Loading interactive exercise

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).

Key takeaway: Model around relationships in SQL; model around exact query access patterns in NoSQL.

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 4
Schema Modeling

1. 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?

Access patterns dictate the database - not hype
Key numbers at this step
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

Relational (PostgreSQL / MySQL)
Best for: Payments, bookings, user accounts, complex queries & ACID

Strengths: Strong ACID guarantees, ad-hoc SQL joins, mature tooling & constraints.

Watch out: Horizontal write sharding is operationally harder than single-node scaling.

Key-Value / Wide-Column (DynamoDB / Cassandra)
Best for: Massive write throughput, time-series logs, user feeds, shopping carts

Strengths: Linear horizontal scaling via partition keys; predictable single-digit-ms reads.

Watch out: No ad-hoc joins; must design partition & sort keys upfront.

Document (MongoDB) / Graph (Neo4j)
Best for: Variable JSON catalogs (Document) or 3+ hop social/fraud graphs (Graph)

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?
Interview tip: Explicitly justify SQL vs. NoSQL using your exact query patterns and consistency needs - never say “NoSQL because big data”.

Knowledge check

Loading quiz

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.

Open AI HLD Practice →SD Interview Q&A
Previous topic
Networking & Protocols
Next topic
Indexing & Storage Engines