Skip main navigation

The CAP triangle

What happens if we have two databases, one in London and one in New York. What if two people try and register the same username in both locations.
3.9
SPEAKER: Relational databases are fantastic at storing data, in particular keeping it consistent and accurate. However, because of the technical design of this class of storage, it can be a problem to store the same data in multiple places at the same time and continue to keep the data consistent and accurate. Let’s think about two databases, one in New York and one in London. These are connected together and interrogated by applications in America and the UK. However, what happens if the same data with different values is written to the databases on both sides of the Atlantic? What will be the correct value to store? For instance, what if two people try and register the same username in both locations.
50.5
Who gets the username? This will be made worse if the network between the two systems breaks. For a short time, both users are registered by both systems. When the network is fixed, which is the correct answer? This is called consistency. Both systems are inconsistent when the network is broken. As a designer, we need to decide what to do in this situation. Should we allow both systems to give different answers to their applications, or should our systems refuse to give an answer at all? We’re going to look at why this is such a problem, and how it can occur. Later in the week, you look at how modern systems can overcome this problem.
95.7
Although they can never fix it completely, they can be pretty good at making it look like there’s no longer a problem.

In the diagram below we can see that there are three relational databases in three locations.

We would like each of these databases to serve the same information to the client computers attached to each of them.

However, each of the clients may be adding and updating information to the data stores, each of the relational databases will be consistent (they will obey the rules of referential integrity internally) but how can we make sure that each database is updated with information from the other databases.

Before we can do that, we need to understand how each of the databases ensure integrity. How can each database ensure that it is internally consistent?

To do that we must understand transactions.

This article is from the free online

Data Science in the Games Industry

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education