SQL vs NoSQL & CAP
Relational databases enforce schema and ACID; NoSQL databases favour flexible schema and horizontal scale.
Cheat sheet
- ▸NoSQL types: Key-Value (Redis), Document (MongoDB), Column-family (Cassandra), Graph (Neo4j).
- ▸CAP: in a network partition choose Consistency or Availability.
- ▸BASE: Basically Available, Soft state, Eventually consistent.
- ▸SQL scales vertically well; NoSQL designed for horizontal sharding.
- ▸Use SQL for transactions/joins; NoSQL for huge scale, flexible or hierarchical data.
- ▸Sharding = horizontal partitioning across servers; replication = copies for availability.
SQL vs NoSQL
| Aspect | SQL | NoSQL |
|---|---|---|
| Schema | Fixed | Flexible |
| Scaling | Vertical (mostly) | Horizontal |
| Transactions | Strong ACID | Often BASE |
| Joins | Native | Limited / denormalize |
| Examples | MySQL, PostgreSQL | MongoDB, Cassandra, Redis |
Top 10 campus interview questions
Quick quiz
1. Redis is a:
2. CAP: during partition you trade off:
3. Neo4j is best for:
4. Horizontal partitioning across servers is:
5. BASE stands for Basically Available, Soft state and: