A transfer is really two updates: one account down, one account up. If the second fails, the first must undo itself. Transactions make that automatic.
1 BEGIN
Opens a transaction. Every change after it belongs to one all-or-nothing unit.
2 COMMIT
Makes every change in the transaction permanent and visible to everyone.
3 ROLLBACK
Discards every change since BEGIN — as if nothing ever happened.
4 ACID
The four promises: Atomic, Consistent, Isolated, Durable. Transactions exist to keep them.
One unit of work
BEGIN1Opens a transaction. Every change after it belongs to one all-or-nothing unit. COMMIT2Makes every change in the transaction permanent and visible to everyone. ROLLBACK3Discards every change since BEGIN — as if nothing ever happened. ACID4The four promises: Atomic, Consistent, Isolated, Durable. Transactions exist to keep them. 4 building blocks make up One unit of work
Press play twice: the first tab commits a clean transfer, the second tab catches a mistake and rolls it back.
BEGIN opens a transaction. From here, every change belongs to one all-or-nothing unit.
Memory
no variables yet — press play
Every transaction ends the same way: one door in, two doors out.
process decision input / output start / end Click a term, then click its promise to lock the pair.
6 conceptsTap a card to expand ?BEGINdrops into place
?COMMITdrops into place
?ROLLBACKdrops into place
?Atomicitydrops into place
?Isolationdrops into place
?Durabilitydrops into place
A debit, then a rollback, then a SELECT. What does the SELECT see?
Your predicted output — one line per console line
Hint: The debit happens inside the transaction, but ROLLBACK cancels everything — the SELECT sees the original 500 and 300.
01A transaction is one all-or-nothing unit of work.
02COMMIT makes it real; ROLLBACK pretends it never happened.
03Mid-transaction changes are private until committed.
04ACID is the promise: atomic, consistent, isolated, durable.
05Wrap any multi-step change in BEGIN and COMMIT — money and inventory love it.