Concept Flow - ACID properties mental model
Start Transaction
Perform Operations
Atomicity
Commit or Rollback
End
This flow shows a transaction starting, operations running, checking ACID properties, then committing or rolling back.
BEGIN TRANSACTION; UPDATE accounts SET balance = balance - 100 WHERE id = 1; UPDATE accounts SET balance = balance + 100 WHERE id = 2; COMMIT;
| Step | Action | Atomicity | Consistency | Isolation | Durability | Result |
|---|---|---|---|---|---|---|
| 1 | BEGIN TRANSACTION | Transaction started as a single unit | Database state is stable before changes | No other transactions interfere yet | Changes not yet permanent | Transaction open |
| 2 | UPDATE account 1 balance -100 | Change recorded but not final | Balance remains consistent (no negative if checked) | Other transactions cannot see partial change | Change in memory, not on disk | Balance decreased in transaction |
| 3 | UPDATE account 2 balance +100 | Change recorded but not final | Total money conserved, consistent state | Isolation maintained, no dirty reads | Change in memory, not on disk | Balance increased in transaction |
| 4 | COMMIT | All changes applied or none | Database moves to new consistent state | Other transactions now see changes | Changes saved permanently on disk | Transaction committed successfully |
| 5 | END | Transaction ends | Database stable | Isolation lifted | Durability ensured | Transaction complete |
| Variable | Start | After Step 2 | After Step 3 | After Step 4 | Final |
|---|---|---|---|---|---|
| account_1_balance | 1000 | 900 | 900 | 900 | 900 |
| account_2_balance | 500 | 500 | 600 | 600 | 600 |
| transaction_state | none | open | open | committed | closed |
ACID properties ensure reliable transactions: Atomicity: all or nothing Consistency: valid data state Isolation: no interference Durability: changes saved Use BEGIN, COMMIT, ROLLBACK to control transactions