Introduction

The CAP theorem, also known as Brewer’s theorem, explains that a distributed database system (DDS) can’t provide more than two of the following three features –                               

  • Consistency

It means that the same data is shown to the users simultaneously, without having anything to do with the node they are connected to. For this action to take place, it must be replicated or forwarded instantly to all other nodes in the system as and when the data is written before the write is deemed to be “successful”. 

For example, when you contact Airtel Customer Care to enquire about your monthly Wi-fi charges, you connect to a random operator. And when you call the next time again to a different operator, they are able to access your records and provide you with the requested service. 

This is known as consistency because even when the customer connects to two different customer care operators, they were able to extract the same information as the customer.

  • Availability

It means that a response is provided to any user requesting the concerning information or data. This concept holds true even when one or more systems are down. In other words, without any exception, all the working nodes in a distributed databases system return a response for any request that is valid. 

Whether the user desires to read or write, and even if the request is a failure, the user should mandatorily get a response. In this manner, each and every operation is bound to terminate. It is of the utmost importance when the user or the client needs to access their data round the clock, even in times of inconsistency. 

  • Partition Tolerance

Sometimes, there can be communication breaks between the distribution databases systems. This can be caused due to lost connections or temporary connections, which may be delayed between 2 nodes. When this happens, one node cannot communicate and receive information from the other node/s in the system. Therefore, it can be said that there is a partition between the two nodes. Some of the primary reasons behind the failure of partition tolerance could be network failure, server crash, or any other similar reason. 

Partition tolerance is something that cannot be avoided while building the database system. Therefore, a distributed system can opt between either consistency or availability but cannot sacrifice partition tolerance. This is also the reason why a NoSQL distributed database is either characterized as AP or CP. Generally, the CA-type databases provide zero distribution since they also work on a single node.

Note:

NoSQL or the non-relational databases are those which are best-tailored for network applications that are distributed over many areas. They are scalable horizontally across a growing network consisting of multiple interconnected computer systems, and they are distributed by design. The NoSQL databases have inadvertently been in the spotlight during this shift that took place in the domain of the distributed databases.

What are the CAP theorem and database?

CAP theorem assumes a huge role in today’s data world. In a DDS of NoSQL type, multiple computing devices working together simultaneously give an idea of a single database unit to the user. The data is stored in multiple nodes. Each of these computer devices communicates with the other in a particular cyber language. 

The CAP theorem talks about the choice that the user has to make between consistency and availability when the network partition is not absent. Eric Brewer argues that the 2 out of 3 concepts are not absolutely right, and it is somewhat misleading because he believes that designers of computer systems only need to sacrifice consistency or availability while the partitions are present. But in several computer systems, partitions are rare. 

According to Eric Brewer, a computer scientist from the University of California, Berkeley, the theorem first came to the spotlight in the year 1998. In 1999, this was published as the CAP principle. And later, in the year 2000, it was presented as a conjecture. In 2002, Nancy Lynch and Seth Gilbert published a formal proof of the conjecture proposed by Brewer and rendered it as a theorem in computer science. Brewer also highlighted the differences between the definitions of consistency as propagated in the CAP theorem as compared to the definition used in ACID.

In 1996, a theorem stating the trade-off between consistency and availability was published by Friedman and Birman, which was similar to the one proposed by Eric. When communication is required between the user and the database systems, the data is suitably transferred to a node in the computer database. The place where the data originates is not disclosed to the user and remains hidden. 

From the point of view of the user, he interacts with the system similar to interaction with a single database. However, internally the nodes communicate the information between them clearly and extract or retrieve the particular data/information that the user is looking for. 

Some of the significant benefits of the distributed system include –

  • Increase in data nodes with more incoming user traffic. 
  • Ease of managing and distributing large user traffic.
  • Relatively cheaper in terms of cost compared to adding more resources to each of the nodes separately.

Thus, it can be said that horizontal scaling is cheaper than vertical scaling in many different ways.

Conclusion

To conclude, it can be said that the CAP theorem can really help an organization to determine the choice of the database. Also, in the case of a partition, it depends on whether the organization chooses to return values that are outdated or no values at all. In case of unavailability in partition, instead of returning nil value, the user could wait a few seconds for the system to return some value. Therefore, it is wise to show some patience and make better-contemplated decisions to either lose out on consistency or availability rather than losing out on both of them. 

In addition, some databases of the NoSQL-type are highly flexible, which means the user can now adjust a few properties here and there to incorporate more consistency and/or availability into the database system.

If you are interested in making a career in the Data Science domain, our 11-month in-person Postgraduate Certificate Diploma in Data Science course can help you immensely in becoming a successful Data Science professional. 

ALSO READ

SHARE
share

Are you ready to build your own career?