🗄️ SQL vs NoSQL Databases
Relational (SQL) Databases
Section titled “Relational (SQL) Databases”- Tabular schema with predefined columns and strong typing.
- Query language: SQL with joins, aggregations, transactions.
- Vertical scaling is common; horizontal sharding available with added complexity.
- ACID guarantees ensure strict transactional integrity.
NoSQL Databases
Section titled “NoSQL Databases”
- Non-relational models designed for large-scale, flexible workloads.
- Schema-free or schema-light; each record can differ.
- Typically emphasize horizontal scale, availability, and lower latency over strict consistency.
| Category | Description | Example Use Cases | Sample Technologies |
|---|---|---|---|
| Key–value | Simple key → value lookups | Caching, session stores | Redis, DynamoDB, Riak |
| Document | JSON/Doc storage with nested structures | CMS, user profiles, catalogs | MongoDB, CouchDB, Firestore |
| Column family | Sparse, column-oriented tables | Time series, analytics, logging | Cassandra, HBase, Bigtable |
| Graph | Nodes + edges for relationships | Social graphs, fraud detection | Neo4j, JanusGraph, Amazon Neptune |
Consistency Models
Section titled “Consistency Models”| Model | Guarantees | Typical Systems |
|---|---|---|
| ACID (Atomicity, Consistency, Isolation, Durability) | Transactions fully succeed or roll back; serializable or snapshot isolation | SQL databases, NewSQL |
| BASE (Basically Available, Soft state, Eventually consistent) | System remains available under partition; replicas converge | Dynamo-style NoSQL, Cassandra |
Decision Matrix
Section titled “Decision Matrix”| Requirement | SQL | NoSQL |
|---|---|---|
| Strong consistency | ✅ | ⚠️ depends (often eventual) |
| Flexible schema | ⚠️ requires migrations | ✅ schema-less |
| Complex joins & relationships | ✅ built-in | ⚠️ denormalize or use graph DB |
| Massive write throughput | ⚠️ sharding required | ✅ native horizontal scale |
| Rapid iteration on data model | ⚠️ slower | ✅ agile |
| Analytics/BI tooling | ✅ mature ecosystem | ⚠️ tool support varies |