DEV Community

Abirami Prabhakar
Abirami Prabhakar

Posted on

Consistency

The consistency property in ACID, is to ensure that the transactions in queries are always in sense and all the constraints are satistfied before executing them and this in terms of wallet system can be a problem if a user tries to debit more than what is in their balance or update data in negative number and those can be stopped by being consistent

Examples of such situations and how an error is prompted to maintain consistency of the data

the balance is updated to negative value

UPDATE accounts 
SET balance = -100 
WHERE name = 'Alice';
Enter fullscreen mode Exit fullscreen mode

an error is prompted

trying to debit more than the users balance

UPDATE accounts 
SET balance = balance - 2000 
WHERE name = 'Bob';
Enter fullscreen mode Exit fullscreen mode

an error is prompted as cuz Bob only has balance of 500 in his account

Changes can be COMMIT only when the data is completely logically correct

Top comments (0)