What are Non Relational Databases?
The same data, stored four different ways. Compare documents, key-value pairs, wide columns and graphs against the relational original — and see what each model makes easy and what it makes painful.
The same data, stored four different ways. Compare documents, key-value pairs, wide columns and graphs against the relational original — and see what each model makes easy and what it makes painful.
"NoSQL" is not one thing. It is four families of database, each dropping a different relational guarantee to buy something else.
A non-relational database stores data in a shape other than fixed tables of rows and columns. The name "NoSQL" is a historical accident — it is best read as "not only SQL", since many of these systems now support SQL-like query languages.
Press "Add field to one record" in each model. In a document store, one document simply gains a field — no migration, no downtime. In the relational model the same change is an ALTER TABLE affecting every row.
The catch: the database no longer guarantees that every record has the same shape, so your application must handle documents that lack the field. Schema enforcement did not disappear — responsibility for it moved into your code.
Document stores deliberately duplicate data so a page can be served with a single read. That is genuinely faster. But you have re-created the update anomaly from the relational lab: change a customer's name and you must now find every document that copied it.
The rule of thumb: relational optimises for correct writes, non-relational optimises for fast reads. Choose based on which one your workload does more of, and how much inconsistency you can tolerate.
There is no "better" model, only different bargains. Relational gives you enforced consistency and flexible ad-hoc queries; non-relational gives you speed, scale and schema freedom in exchange for moving integrity into your application. Most real systems today use both.
The same data, stored four different ways. Compare documents, key-value pairs, wide columns and graphs against the relational original — and see what each model makes easy and what it makes painful.