DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Related

  • Manual Sharding in PostgreSQL: A Step-by-Step Implementation Guide
  • Why Database Migrations Take Months and How to Speed Them Up
  • Unmasking Entity-Based Data Masking: Best Practices 2025
  • How Trustworthy Is Big Data?

Trending

  • How to Ensure Cross-Time Zone Data Integrity and Consistency in Global Data Pipelines
  • GitHub Copilot's New AI Coding Agent Saves Developers Time – And Requires Their Oversight
  • Accelerating Debugging in Integration Testing: An Efficient Search-Based Workflow for Impact Localization
  • Orchestrating Microservices with Dapr: A Unified Approach
  1. DZone
  2. Data Engineering
  3. Databases
  4. Quick Notes: What is CAP Theorem?

Quick Notes: What is CAP Theorem?

CAP theorem states that any database system can only attain two out of following states which is Consistency, Availability and Partition Tolerance.

By 
Ajitesh Kumar user avatar
Ajitesh Kumar
·
May. 05, 15 · Interview
Likes (3)
Comment
Save
Tweet
Share
25.9K Views

Join the DZone community and get the full member experience.

Join For Free

this article briefly talks about what is cap theorem and provides appropriate examples. i have come across many candidates appearing for architect interviews who failed to answer questions like:

  • what is cap theorem?
  • rdbms system such as oracle achieves which of the following two: consistency, availability, partition tolerance
  • nosql datastore such as hbase tends to achieve which of the following two: consistency, availability, partition tolerance

the article below addresses some of the above questions. please feel free to comment/suggest if i missed to mention one or more important points. also, sorry for the typos.

following points are discussed later in this article:

  • what is cap theorem?
  • some examples of db system vis-a-vis cap theorem
  • which db system to choose based on cap requirements?


what is cap theorem?

cap theorem states that any database system can only attain two out of following states which is consistency, availability and partition tolerance. following is a brief definition of these three terms:

  • consistency: any changes to a particular record stored in database, in form of inserts, updates or deletes is seen as it is, by other users accessing that record at that particular time. if they don’t see the updated data, it is termed as eventual consistency.
  • availability: the system continues to work and serve data inspite of node failures.
  • partition tolerance: the database system could be stored based on distributed architecture such as hadoop (hdfs).

following diagram depicts the above three terms:

cap theorem - consistency, availability, partition tolerance

cap theorem – consistency, availability, partition tolerance

following are some of the urls of pages where further details could be found:

  • cap theorem on wikipedia
  • cap theorem: revisited
some examples of db system vis-a-vis cap theorum
  • rdbms systems such as oracle, mysql etc supports consistency and availability.
  • nosql datastore such as hbase supports consistency and partition tolerance.
  • nosql datastore such as cassandra, couchdb supports availability and partition tolerance.
which db system to choose based on cap requirements?
  • cp-based database system: when it is critical that all clients see a consistent view of the database, the users of one node will have to wait for any other nodes to come into agreement before being able to read or write to the database, availability takes a backseat to consistency and one may want to choose database such as hbase that supports cp (consistency and partition tolerance)
  • ap-based database system: when there is a requirement that database remain available at all times, one could db system which allows clients write data to one node of the database without waiting for other nodes to come into agreement. db system then takes care of data reconciliation at a little later time. this is the state of eventual consistency. in applications which could sacrifice data consistency in return of huge performance, one could select databases such as couchdb, cassandra.

Database Theorem

Published at DZone with permission of Ajitesh Kumar, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Manual Sharding in PostgreSQL: A Step-by-Step Implementation Guide
  • Why Database Migrations Take Months and How to Speed Them Up
  • Unmasking Entity-Based Data Masking: Best Practices 2025
  • How Trustworthy Is Big Data?

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: