Bird
Raised Fist0
DBMS Theoryknowledge~20 mins

CAP theorem in DBMS Theory - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
CAP Theorem Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding CAP theorem trade-offs

In a distributed database system, which two properties can be guaranteed simultaneously according to the CAP theorem?

AConsistency and Availability
BConsistency, Availability, and Partition Tolerance
CConsistency and Partition Tolerance
DAvailability and Partition Tolerance
Attempts:
2 left
💡 Hint

Remember, network failures can happen, so the system must handle partitions.

Architecture
intermediate
2:00remaining
Design choice under network partition

You are designing a distributed key-value store. During a network partition, you want the system to always respond to client requests even if some nodes are unreachable. Which CAP property are you prioritizing?

AAvailability
BConsistency
CPartition Tolerance
DNeither Consistency nor Availability
Attempts:
2 left
💡 Hint

Think about whether the system responds or waits during partitions.

scaling
advanced
2:30remaining
Scaling a distributed system with CAP constraints

You want to scale a distributed database across multiple data centers worldwide. Network partitions are common. To maintain strong consistency, what is the likely impact on system availability?

AAvailability remains unaffected by consistency choices.
BAvailability will increase because more nodes can serve requests independently.
CAvailability will increase because partitions are ignored.
DAvailability will decrease because the system waits for all nodes to agree.
Attempts:
2 left
💡 Hint

Strong consistency requires coordination among nodes.

tradeoff
advanced
2:30remaining
Choosing CAP properties for a social media feed

A social media platform wants to ensure users always see the latest posts but can tolerate some delays during network issues. Which CAP property combination best fits this need?

AConsistency and Partition Tolerance
BAvailability and Partition Tolerance
CConsistency and Availability
DOnly Availability
Attempts:
2 left
💡 Hint

Latest posts mean strong consistency is important.

estimation
expert
3:00remaining
Estimating system behavior under CAP constraints

A distributed database replicates data across 5 nodes. During a network partition, 2 nodes become unreachable. If the system prioritizes availability over consistency, how many nodes must respond to a read request to maintain availability?

AAt least 2 nodes must respond
BOnly 1 node must respond
CAll 5 nodes must respond
DAt least 3 nodes must respond
Attempts:
2 left
💡 Hint

Availability means responding even if some nodes are down.

Practice

(1/5)
1. What does the CAP theorem state about distributed systems?
easy
A. A distributed system can only guarantee two out of Consistency, Availability, and Partition tolerance at the same time.
B. A distributed system can guarantee all three: Consistency, Availability, and Partition tolerance simultaneously.
C. CAP theorem applies only to single-node databases.
D. CAP theorem states that Consistency is always more important than Availability.

Solution

  1. Step 1: Understand the CAP theorem basics

    The CAP theorem says a distributed system cannot guarantee Consistency, Availability, and Partition tolerance all at once.
  2. Step 2: Identify the correct statement

    Only two of these three properties can be guaranteed simultaneously in a distributed system.
  3. Final Answer:

    A distributed system can only guarantee two out of Consistency, Availability, and Partition tolerance at the same time. -> Option A
  4. Quick Check:

    CAP theorem = Two guarantees only [OK]
Hint: Remember CAP means pick any two out of three [OK]
Common Mistakes:
  • Thinking all three guarantees are possible simultaneously
  • Confusing CAP theorem with ACID properties
  • Assuming CAP applies to single-node systems
2. Which of the following is a correct example of a system prioritizing Availability over Consistency according to CAP theorem?
easy
A. A DNS system that always responds to queries even if some data is outdated.
B. A system that never allows network partitions.
C. A system that stops responding during network partitions to avoid inconsistent data.
D. A banking system that locks accounts during transactions to ensure exact balances.

Solution

  1. Step 1: Identify Availability over Consistency example

    Availability means the system always responds, even if data might be stale or inconsistent.
  2. Step 2: Match example to definition

    DNS systems prioritize Availability by responding to queries despite possible outdated data during partitions.
  3. Final Answer:

    A DNS system that always responds to queries even if some data is outdated. -> Option A
  4. Quick Check:

    Availability > Consistency example = DNS [OK]
Hint: Availability means always respond, even if data is stale [OK]
Common Mistakes:
  • Confusing locking with Availability
  • Thinking systems can avoid network partitions
  • Assuming consistency means always available
3. Consider a distributed database that chooses Consistency and Partition tolerance but sacrifices Availability during network failures. What happens when a network partition occurs?
medium
A. The system automatically heals the network partition.
B. The system continues to serve all requests with possibly stale data.
C. The system ignores partitions and may return inconsistent data.
D. The system refuses to respond to some requests to maintain data consistency.

Solution

  1. Step 1: Analyze system choice of Consistency and Partition tolerance

    Choosing Consistency and Partition tolerance means the system must maintain data correctness and handle network splits.
  2. Step 2: Understand impact on Availability

    To keep Consistency during partitions, the system sacrifices Availability by refusing some requests.
  3. Final Answer:

    The system refuses to respond to some requests to maintain data consistency. -> Option D
  4. Quick Check:

    Consistency + Partition tolerance = sacrifice Availability [OK]
Hint: Consistency + Partition tolerance means some requests denied [OK]
Common Mistakes:
  • Assuming system serves stale data when consistency chosen
  • Thinking partitions are automatically fixed
  • Confusing availability with consistency guarantees
4. A developer claims their distributed system guarantees Consistency, Availability, and Partition tolerance simultaneously. What is the most likely issue?
medium
A. The system uses eventual consistency correctly.
B. The system is ignoring network partitions or not truly distributed.
C. The system is using a single-node database.
D. The system is using a caching layer to improve performance.

Solution

  1. Step 1: Recall CAP theorem limitation

    CAP theorem states all three guarantees cannot be met simultaneously in a distributed system.
  2. Step 2: Identify why claim is incorrect

    If a system claims all three, it likely ignores partitions or is not truly distributed.
  3. Final Answer:

    The system is ignoring network partitions or not truly distributed. -> Option B
  4. Quick Check:

    All three guarantees impossible in distributed system [OK]
Hint: All three guarantees mean system is not truly distributed [OK]
Common Mistakes:
  • Believing eventual consistency means full consistency
  • Confusing caching with consistency guarantees
  • Ignoring network partitions in design
5. You are designing a global e-commerce platform that must remain available during network partitions but can tolerate some temporary inconsistency. According to CAP theorem, which two properties should you prioritize?
hard
A. Consistency and Partition tolerance
B. Consistency and Availability
C. Availability and Partition tolerance
D. Only Availability

Solution

  1. Step 1: Understand system requirements

    The platform must remain available during network partitions and can tolerate temporary inconsistency.
  2. Step 2: Match requirements to CAP properties

    Availability and Partition tolerance must be prioritized, sacrificing strict Consistency temporarily.
  3. Final Answer:

    Availability and Partition tolerance -> Option C
  4. Quick Check:

    Available + Partition tolerant = temporary inconsistency allowed [OK]
Hint: Availability + Partition tolerance means accept temporary inconsistency [OK]
Common Mistakes:
  • Choosing Consistency when availability is required
  • Ignoring partition tolerance in global systems
  • Assuming all three properties can be guaranteed