Compare relational and NoSQL databases.
Skip to solutionKEEP THE
mediumSystem Design
When would you choose SQL vs NoSQL?
1.1k views
01
Understand the problem
databasesql-nosql
02
Attempt it yourself
Sketch your approach before reading the solution — that's what interviews test.
Nudge consolestandby
Stuck? Beam a request up — the console returns a conceptual nudge that guides your logic without spoiling the implementation.
03
Study the solution
SQL vs. NoSQL: When Would You Choose Which?
Target Audience: Junior & Senior Software Engineers preparing for System Design Interviews — no prior system design knowledge assumed. Difficulty: Easy to Medium
How to read this doc: Every concept is explained in plain language first. Right after, you'll se
Solution ready — 2 min read
Classified // press E to declassify
04
Read the code
Relational schema (SQL)
-- Normalized: users and orders in separate tables, joined by user_id
CREATE TABLE users (
id BIGINT PRIMARY KEY,
email TEXT UNIQUE NOT NULL,
name TEXT NOT NULL
);
CREATE TABLE orders (
id BIGINT PRIMARY KEY,
user_id BIGINT NOT NULL REFERENCES users(id),
total_cents INT NOT NULL,
created_at TIMESTAMPTZ DEFAULT now()
);
-- Read needs a join:
SELECT u.name, o.total_cents
FROM orders o JOIN users u ON u.id = o.user_id
WHERE u.email = 'ada@example.com';Document model (NoSQL)
Run Playground// Same data denormalized into ONE document — no joins, one read.
{
"_id": "user_42",
"email": "ada@example.com",
"name": "Ada",
"orders": [
{ "id": "o_1", "totalCents": 4999, "createdAt": "2024-01-04T10:00:00Z" },
{ "id": "o_2", "totalCents": 1200, "createdAt": "2024-02-11T08:30:00Z" }
]
}05
Join the discussion
Discussion (0)
Sign in to join the discussion.
No responses yet. Be the first to share what you think.
Transmission complete // awaiting log
KEEP THE
STREAK ALIVE.
Dossier 7 of 99 decoded in the System Design track. One more won't hurt.