CONSISTENCY (Acid)
The state of before, during or after a transaction needs to be consistent and valid
For example, considering the following transaction of money transfering from Alice to Bob
ALICE.BALANCE = 1000
BOB.BALANCE = 800
BEGIN TRANSACTION
ALICE.BALANCE - 500
BOB.BALANCE + 500
END TRANSACTION
So in a consistent environment, if we have a query of QUERY_SUM(ALICE, BOB) that query the sum of balance of both Alice and Bob happening in the background it has to be 1800 at all the time even during the transaction.
So
| Thread 1 | Thread 2 |
|---|---|
QUERY_SUM(ALICE, BOB) -> 1800 | |
ALICE.BALANCE - 500 | |
QUERY_SUM(ALICE, BOB) -> 1800 | |
BOB.BALANCE + 500 | |
QUERY_SUM(ALICE, BOB) -> 1800 |
As a result, we can see that in Thread2, doesn't matter when we perform QUERY_SUM, result is still consistent and valid