Why \"SQL vs NoSQL\" is a cost question, not a category
Every schema moves cost between reads and writes: normalised layouts pay on read and keep one truth, denormalised layouts pay on write and must keep copies consistent.
The useful question is which operation pays. A relational store keeps each fact in one place and joins related facts when a query runs, so a read touches many places and a write touches one. A document or wide-column store copies data into the shape it is read in, so a read touches one partition while every write must update every copy. The label on a database does not tell you which bill arrives.
Consider a train route. In a normalised schema, a station's name lives in one stations row, and a train-stop table holds a foreign key pointing at it. Reading the route means joining train, train-stop, station and line. The engine finds the matching row in each table through an index, so a join of four tables is four index lookups. Renaming a station is one update to one row. Store the same route as one document that lists its stations with names and sequence numbers instead, and reading it becomes one fetch from one partition. The cost moves to writes, because a renamed station must be edited in every route document that mentions it, and each copy is a place where the change can fail to land.
The abstraction hides the write that did not finish. Suppose a station closes and the application must update three route documents on three partitions. Two succeed, and the third write times out. Nothing in the store objects, because a document store does not enforce a foreign key or a cross-document rule. The system now serves a route through a closed station until something notices. One bad copy is already an inconsistency, and a fact copied two to ten times gives that failure many places to hide. Schema enforcement has moved into application code, so every writer must repeat the same checks, and a missed check is a bug that no latency graph will show. The normalised schema cannot enter this state: the single update either commits or it does not, and every join sees the same committed row.
Decide by the access unit, not the database family. Write down what one read fetches and how many places one write must touch. If a read wants one self-contained thing whose fields change together, such as a post, a chat message or a sensor reading, denormalise. Put the whole thing in one partition and accept copies only where the same value appears in several records. If facts are shared, change independently, and must never disagree, such as an account and its balance, normalise and accept the read lookups. Keep the transaction guarantees for that case, and check the store actually provides them. If it does not, write the constraint in application code and test it under concurrent writes. Count copies before you ship, and move any fact with many copies to one home.
- Index lookups per join
- 4
- Partitions per read
- 1
- Duplication factor
- 2 to 10
- Inconsistent copies
- 1
Each table in a four-table join needs one index lookup, and those lookups happen on every read that joins.
A denormalised read fetches one self-contained record from one partition, so the read never joins across nodes.
Each fact is stored in several records, shaped for the read that uses it, and every write must update all of them.
A single stale copy already breaks the fact, so one failed write is enough to produce a wrong answer.
At Omio the search index ran on a document store because a route result is a document: departure, arrival, legs, price, operator, and a dozen attributes the UI renders straight through. It beat the relational version, which needed six joins per card. Then the network team moved a station's access rules and the fan-out showed up in the on-call queue.
The wall is that a document is not a transaction. A station closure touched a hundred thousand route documents across every partition, and the writer that pushed the update died at ninety percent. Copies disagreed with each other, so two customers on the same day saw different platforms, and nothing in the store objected. Duplication had turned one fact into a hundred thousand chances to be wrong.
We tried the obvious things first. Re-running the update on failure made it slower, not safer. A reconciliation job that diffed station state against the index cost more than the index itself. Adding a foreign key proved impossible in the store we had chosen, which was the point of choosing it.
What stuck was splitting the fact by how often it changes. Legs, prices and availability stayed denormalised, because they change together and are read as one card. Station and operator reference data moved back to the relational store and is joined at read time, cached for a minute. The rule became: duplicate what changes together, join what changes independently.