Transactions

  • A transaction groups several writes so they succeed together or not at all 5:06.
  • Canonical example: debiting one account and crediting another inside one transaction 5:06.
  • Failure scenario without transactions: customer A is debited 100, the credit step fails — account B never receives the money and account A has lost it 5:35.
  • Rule of thumb: always use transactions — it's all or nothing, then you commit 5:35.

ACID — the characteristics of transactions

PropertyMeaning
AtomicityAll writes happen or none do
ConsistencyRules and constraints always hold
IsolationConcurrent transactions don't corrupt each other
DurabilityOnce committed, it survives a crash

All four defined at 5:35–6:29.