SQL vs NoSQL: the real decision tree
Few debates generate more heat and less light than "SQL vs NoSQL." Strip away a decade of marketing and tribal identity, and what remains is a set of concrete trades. Let's lay out what each side actually gives you and actually costs you — and end with a decision tree you can defend to a hostile audience.
What relational databases actually give you
- Multi-row ACID transactions. The headline feature and the whole reason the category exists: change several rows across several tables, and either all of it happens or none does. Move money between accounts, decrement stock while creating an order — if two things must change together or not at all, this is not a nice-to-have, it is the requirement.
- Ad-hoc queries. SQL lets you answer questions you didn't anticipate when designing the schema. "Which customers bought X but not Y, by region, last quarter?" — never planned for, answered in one query. This flexibility is worth far more than people realise, right up until the day they lose it.
- Enforced constraints. Foreign keys, uniqueness, checks — the database itself refuses to hold invalid data. Why that matters: every application eventually gets a second writer — a batch job, a migration script, an intern's admin tool — and application-level validation only guards the paths that remembered to validate. The constraint guards all of them, forever.
What NoSQL is really about — and what you give up to get it
First, clear the fog: NoSQL is not "SQL but faster." It's a family of systems that each deleted some relational guarantees to buy something specific. Different members deleted different things:
- Document stores (MongoDB, DynamoDB): store JSON-ish documents by key. Bought: horizontal scale and schema flexibility. Paid: joins are gone, and access patterns must be known in advance and baked into how you key the data — great when you always fetch "the whole user profile," painful when tomorrow's feature needs a slice you didn't plan. Referential integrity is now your application's job.
- Wide-column (Cassandra, HBase): Bought: enormous write throughput and near-linear scaling across machines (these are LSM engines — Lesson 3.01 pays off). Paid: you design one table per query, denormalise aggressively, and accept that a new access pattern may mean a new table and a full backfill of existing data.
- Key-value (Redis, Memcached): Bought: sub-millisecond lookups. Paid: no query language at all — you get, you set, that's the deal. Perfect for caches, sessions, counters, leaderboards, rate limiters.
- Graph (Neo4j): Bought: multi-hop relationship traversals — "friends of friends who work at X" — that would be six agonising self-joins in SQL. Paid: a specialised engine you run for that one class of question.
The actual decision tree — walk it in order
- Do two or more entities need to change atomically? → Relational. Stop reading, you're done.
- Will you need to answer questions you haven't thought of yet? → Relational. (For most products, honestly: yes, you will.)
- Is write volume genuinely beyond one big machine plus replicas? → Wide-column. Note the word genuinely — do the Tier 0 math first.
- Flat lookups by a known key, at extreme volume or speed? → Key-value or document.
- Is the interesting question about relationships several hops out? → Graph.
"We chose NoSQL for scale" — at 200 requests per second. Postgres does that on a laptop, literally. And the flexibility argument has aged badly too: modern Postgres has JSONB (schemaless documents inside a relational database), native partitioning, and logical replication. The professional default in 2026: pick relational, and write down the specific reason if you leave. "It's what scale-companies use" is not a specific reason; "our write volume is 400k/sec of append-only events" is.