Lesson 4 of 8Article15 min
Transactions and ACID Properties
Transactions and ACID Properties
ACID explained
- Atomicity: all operations succeed or none do.
- Consistency: constraints remain valid after commit.
- Isolation: concurrent transactions do not corrupt each other.
- Durability: committed data survives crashes.
Transfer money safely
Financial and inventory systems rely on transactions so partial updates never leak into user-visible state.
Transaction block example
BEGIN;
UPDATE accounts
SET balance = balance - 500
WHERE account_id = 101;
UPDATE accounts
SET balance = balance + 500
WHERE account_id = 202;
COMMIT;
-- If anything fails, ROLLBACK;