The short answer
SQL (relational) databases store data in tables with a fixed schema, and rows in different tables are linked by keys. They use SQL for queries and offer ACID transactions. Examples are PostgreSQL, MySQL and SQL Server.
NoSQL databases is a broad label for databases that do not use the model. They come in several kinds:
- Document: stores JSON-like documents, for example MongoDB.
- Key-value: stores a value under a key, for example Redis.
- Wide-column: stores rows with flexible columns, for example Cassandra.
- Graph: stores nodes and relationships, for example Neo4j.
| SQL | NoSQL | |
|---|---|---|
| Schema | fixed, defined first | flexible, can change per record |
| Relationships | joins between tables | usually stored inside one record |
| Transactions | strong ACID | varies, often weaker across records |
| Scaling | usually scale up one server, with read replicas | often built to spread across many servers |
When to choose SQL: the data is structured, the relationships matter, and correctness is important, as in payments, orders and inventory.
When to choose NoSQL: the data shape varies a lot, you need very high write volume or very low latency at large scale, or the data is naturally a document or a graph, such as a product catalogue or a social network.
A common mistake is to say NoSQL is faster. It is not faster in general. It is faster for the access patterns it was designed for. Many systems use both: a relational database for orders, and a key-value store for caching sessions.
Interview shortcut
> Pick SQL when relationships and correctness matter. Pick NoSQL when the shape or the scale does not fit tables.