A comprehensive comparison of popular SQL and NoSQL databases, what they are known for, and how they handle CAP Theorem trade-offs.


๐Ÿงฎ Relational Databases (SQL)

DatabaseTypeKnown ForCAP Trade-off
PostgreSQLSQLFeature-rich, ACID-compliant, extensible (PostGIS, full-text search)CP
MySQLSQLFast, simple, widely used (with InnoDB); configurable durabilityCP
MariaDBSQLMySQL fork, better performance and open-source friendlyCP
SQLiteSQLLightweight, embedded, perfect for mobile appsCA (not distributed)
SQL ServerSQLEnterprise-grade, strong tooling and integrationCP
Oracle DBSQLStrong consistency and enterprise featuresCP

๐Ÿ“ฆ NoSQL Databases

๐Ÿ“‘ Document Stores

DatabaseTypeKnown ForCAP Trade-off
MongoDBNoSQL (Document)JSON-like docs, flexible schema, powerful indexingCP (default), AP (eventual mode)
CouchDBNoSQL (Document)MVCC, replication-first, offline syncAP
FirestoreNoSQL (Document)Realtime sync, scalable for mobile/web appsAP

๐Ÿ”‘ Key-Value Stores

DatabaseTypeKnown ForCAP Trade-off
RedisNoSQL (Key-Value)In-memory speed, pub/sub, cachingCA (single-node), AP (cluster)
DynamoDBNoSQL (KV/Doc)Managed, scalable, high-availability, AWS-nativeAP
RiakNoSQL (Key-Value)High availability and fault toleranceAP

๐Ÿงพ Wide-Column Stores

DatabaseTypeKnown ForCAP Trade-off
CassandraNoSQL (Wide-Column)Write-heavy, scalable, eventual consistencyAP
HBaseNoSQL (Wide-Column)Built on Hadoop, used in Big Data systemsCP
ScyllaDBNoSQL (Wide-Column)Cassandra-compatible, built for performance in C++AP

๐Ÿ”— Graph Databases

DatabaseTypeKnown ForCAP Trade-off
Neo4jNoSQL (Graph)Graph relationships, Cypher query languageCP
ArangoDBMulti-modelSupports document, KV, and graph modelsCP (configurable)
JanusGraphGraph backendScales over Cassandra, HBase โ€” inherits their CAP traitsInherited (CP/AP)

๐Ÿง  CAP Theorem Summary

PropertyMeaning
C - ConsistencyAll nodes return the most recent committed data
A - AvailabilityEvery request gets a non-error response (even if stale)
P - Partition ToleranceThe system continues to operate despite network splits

In distributed systems, you can only guarantee 2 of 3: C, A, and P.


๐Ÿงญ When to Use What?

  • ACID Transactions โ†’ PostgreSQL, MySQL, Oracle
  • Flexible schema โ†’ MongoDB, DynamoDB
  • Horizontal scalability โ†’ Cassandra, DynamoDB
  • In-memory speed โ†’ Redis
  • Graph queries โ†’ Neo4j, ArangoDB
  • Offline/mobile โ†’ SQLite, Firestore

๐Ÿ’ก Tip: CAP trade-offs are not always strictโ€”many modern databases let you choose between strong and eventual consistency modes depending on your use case.