Databases
SQL vs NoSQL
SQL (relational) databases store data in tables with a fixed schema and use SQL for queries. NoSQL databases cover document, key-value, column, and graph stores with flexible schemas.
Side-by-side comparison
| SQL | NoSQL | |
|---|---|---|
| Schema | Fixed, enforced | Flexible / dynamic |
| Query language | SQL (standardized) | Varies by database |
| Relationships | Joins, foreign keys | Denormalized / embedded |
| Transactions | Strong ACID | Varies (often eventual consistency) |
| Scaling | Vertical (mostly) | Horizontal (designed for it) |
When to use SQL
- Structured data with clear relationships
- You need strong consistency and transactions
- Complex queries and reporting
When to use NoSQL
- Rapidly changing or unstructured data
- Massive horizontal scale
- High write throughput with flexible documents
Bottom line
Choose SQL for structured, relational data needing strong consistency. Choose NoSQL for flexible schemas and horizontal scale. Many systems use both.