Consistency
Understand how consistency ensures databases transition between valid states by enforcing rules and constraints. Explore examples using unique and foreign key constraints, and learn the role of application developers in defining these consistency guarantees.
We'll cover the following...
Consistency guarantees ensure that the database moves from one valid state to another. During a transition phase, the database ensures it satisfies all the rules and constraints.
Consistency is a user-defined guarantee. The responsibility of defining the rules and constraints lies with the application developers. Therefore, the database doesn’t play a significant role in maintaining consistency guarantees.
Let’s take a look at some different scenarios to explain this guarantee.
Scenario 1
Person A transfers $100 to person B. Person A’s balance before the transaction was $300 and person B’s balance before the transaction was $400. Consistency guarantees should ensure that the sum of the balances before the transaction should be equal to the sum of balances after the transaction.
Sum of balances before the transaction:
$300+$400=$700.After the transaction, person A’s balance decreases to
$200and person B's balance increases to$500.The sum of balances after the transaction:
$200...