Premium Chapter

Transactions & concurrency

Computer Science & Applications (Paper 2) (Code 87) · Unit 4 · ~16 min read · Original chapter

Free previewPremium full chapter

Free preview

A transaction is a unit of work that must be treated as a whole: either all of it happens, or none of it does. A bank transfer that debits one account but never credits the other would be a disaster, and the database must make that impossible even when the power fails mid-transfer. The four guarantees are ACID: Atomicity (all or nothing), Consistency (valid state to valid state), Isolation (concurrent transactions behave as if serial) and Durability (committed work survives crashes). Worked example — the lost update: two transactions both read a balance of 100, both add 50, and both write back 150, so one deposit is lost and the balance should have been 200. Concurrency control exists to stop exactly this.

Checking premium access…