Tables with strict rules, or flexible shapes that scale out? How to choose.
SQL (relational) databases keep data in tables with a fixed shape and strong safety rules. NoSQL is a loose name for everything else: flexible shapes, and usually an easier way to spread data over many machines.
SQL stands for Structured Query Language, the language used to ask relational databases questions. A relational database stores data in tables. Every row has the same columns, and tables link to each other through keys.
NoSQL means โnot only SQLโ. It covers many designs that do not use the classic table model. Most of them trade some of SQL's strict rules for flexibility or easy scaling.
{
"order": 1001,
"user": { "name": "Asha" },
"items": [
{ "product": "pen", "qty": 2 },
{ "product": "book", "qty": 1 }
]
}| SQL (relational) | NoSQL | |
|---|---|---|
| Data shape | Tables, fixed columns | Documents, key-value, wide column, graph |
| Schema | Defined first (schema-on-write) | Flexible, often checked by the app (schema-on-read) |
| Relationships | Foreign keys and joins | Embed data, or link by id in app code |
| Transactions | Full ACID across rows and tables | Varies. Often per record, some now support more |
| Scaling | Scale up first. Scale out with read replicas, sharding or newer distributed SQL | Designed to scale out |
| Consistency | Strong by default | Often tunable, sometimes eventual |
| Query power | SQL: very rich and ad hoc | Depends. Best at queries you planned for |
| Examples | PostgreSQL, MySQL, SQL Server, Oracle | MongoDB, Cassandra, DynamoDB, Redis, Neo4j |
A teaching model with made-up weights and round numbers. Real answers depend on hardware, the exact product and your team. Modern SQL databases can scale out (Spanner, CockroachDB, Vitess) and many NoSQL ones offer transactions, so the line is blurry.
| Term | Meaning in easy words |
|---|---|
| SQL | The standard language for asking relational databases questions |
| NoSQL | A broad name for non-relational databases: not only SQL |
| Schema | The agreed shape of the data: columns, types and rules |
| Join | Combining rows from tables by a shared key |
| Normalisation | Splitting data so each fact is stored once |
| Denormalisation | Copying data on purpose so one read gets everything |
| Vertical scaling | Making one machine bigger |
| Horizontal scaling | Adding more machines |
| Eventual consistency | Copies may differ for a short time but agree later |
| Distributed SQL | SQL databases built to spread over many machines (Spanner, CockroachDB) |
| Choice | We gain | We lose |
|---|---|---|
| Fixed schema | Safety and clarity | Slower changes |
| Flexible schema | Speed of change | Bugs from inconsistent data |
| Normalised data | No duplicate facts | Joins on every read |
| Denormalised data | Fast reads | More writes and risk of drift |
| Strong consistency | Always correct | More latency, harder to spread |
| Eventual consistency | Speed and availability | Readers may see old data |