CSC475 ยท 2081 ยท 5 marks
What is the CAP theorem? Explain.
What is the CAP theorem? Explain. [5]
Quick answer
The CAP Theorem (also known as Brewer's Theorem) is a theoretical framework in distributed database systems. CAP stands for: C - Consistency; A - Availability; P - Partition Tolerance.
CAP Theorem
Definition
The CAP Theorem (also known as Brewer's Theorem) is a theoretical framework in distributed database systems. CAP stands for:
- C - Consistency
- A - Availability
- P - Partition Tolerance
The theorem states that a distributed database system can guarantee at most two out of these three properties simultaneously - it is impossible to achieve all three at the same time.
Explanation of the Three Properties
| Property | Description |
|---|---|
| Consistency | Every read receives the most recent write or an error. All nodes in the system see the same data at the same time. |
| Availability | Every request receives a response (not necessarily the most recent data). The system remains operational at all times. |
| Partition Tolerance | The system continues to operate even when network partitions (communication breakdowns between nodes) occur. |
Classification of Distributed Systems
Based on the CAP theorem, distributed systems are classified into three categories:
-
CA Systems (Consistency + Availability): Sacrifice partition tolerance. Work well in single-node or non-distributed environments. Example: Traditional RDBMS.
-
CP Systems (Consistency + Partition Tolerance): Sacrifice availability. When a partition occurs, the system may refuse to respond rather than return inconsistent data. Example: HBase, MongoDB.
-
AP Systems (Availability + Partition Tolerance): Sacrifice consistency. The system remains available even during partitions but may return stale data. Example: Cassandra, CouchDB.
Significance in NoSQL
The CAP theorem is especially important for understanding NoSQL systems. NoSQL databases cannot provide all three guarantees together, so designers must choose which two properties are most critical for their use case. This trade-off guides the selection of the appropriate NoSQL database for a given application.
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.