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

Related

  • Liquibase: Database Change Management and Automated Deployments
  • AWS Managed Database Observability: Monitoring DynamoDB, ElastiCache, and Redshift Beyond CloudWatch
  • Production Database Migration or Modernization: A Comprehensive Planning Guide [Part 2]
  • S3 Vectors: How to Build a RAG Without a Vector Database

Trending

  • How AI Coding Assistants Are Changing Developer Flow
  • Stop Using the ATM-Didn’t-Kill-Jobs Story to Reassure Developers About AI
  • Java Backend Development in the Era of Kubernetes and Docker
  • The Death of "Text-Only" ChatOps: Why Google's A2UI Matters for DevOps and SRE
  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
26.3K 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. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Liquibase: Database Change Management and Automated Deployments
  • AWS Managed Database Observability: Monitoring DynamoDB, ElastiCache, and Redshift Beyond CloudWatch
  • Production Database Migration or Modernization: A Comprehensive Planning Guide [Part 2]
  • S3 Vectors: How to Build a RAG Without a Vector Database

Partner Resources

×

Comments

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

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

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 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook