Course contentsShow
← Computer Science
Lesson 1714 of 2,87239. NoSQL and Modern DatabasesFree lesson

CAP Theorem Trade-offs Across Categories

How different NoSQL categories make different choices between consistency, availability, and partition tolerance.

CAP Theorem Trade-offs Across Categories

You'll learn how different NoSQL database categories prioritize consistency, availability, and partition tolerance differently based on their design goals.

The CAP Theorem Recap

The CAP theorem states that a distributed database can only guarantee two of three properties simultaneously:

  • Consistency (C): All nodes see the same data at the same time
  • Availability (A): Every request receives a response (success or failure)
  • Partition tolerance (P): The system continues operating despite network splits

Since network partitions are inevitable in distributed systems, the real choice is between CP (consistency + partition tolerance) or AP (availability + partition tolerance).

How NoSQL Categories Choose

Document Stores (e.g., MongoDB)

Typically CP-leaning. They prioritize consistency, ensuring all nodes have the same data before acknowledging writes. During a partition, some nodes may become unavailable to prevent serving stale data.

Key-Value Stores (e.g., DynamoDB, Riak)

Often AP-leaning. They favor availability and eventual consistency, allowing reads and writes to continue even during partitions. Data synchronizes later, accepting temporary inconsistencies.

Column Family Stores (e.g., Cassandra)

Usually AP-tunable. They offer configurable consistency levels—you can choose per-query whether you want stronger consistency (fewer available nodes respond) or higher availability (accept eventual consistency).

Graph Databases (e.g., Neo4j)

Generally CA-leaning in single-node setups, but shift to CP when distributed. Graph traversals require consistency to maintain relationship integrity, so they sacrifice availability during partitions.

The Practical Reality

Most modern NoSQL databases don't enforce strict CAP boundaries—they offer tunable consistency where you adjust the trade-off per operation based on your application's needs.

Key Takeaway: NoSQL categories make different CAP trade-offs by design: document stores lean CP for data integrity, key-value and column family stores lean AP for scale and availability, while graph databases prioritize CP to preserve relationship consistency.