ACID Transaction Properties
The ACID guarantees
ACID is an acronym for the four properties that a DBMS guarantees for transactions:
| Property | Meaning |
|---|---|
| Atomicity | All changes are performed as a single operation, or none are |
| Consistency | A transaction transforms the database from one consistent state to another |
| Isolation | Concurrent transactions do not see each other’s intermediate state |
| Durability | Once committed, changes survive system failures |
Atomicity
All changes to data are performed as if they are a single operation. All the changes are performed, or none of them are.
Example: in a funds transfer, if a debit is made from one account, the corresponding credit must be made to the other account. If the system fails after the debit but before the credit, atomicity ensures that the debit is rolled back. Neither half-effect survives.
Consistency
Every transaction applied to a consistent database leaves it in a consistent state. The database has integrity constraints (declared in the schema), and a valid transaction must preserve them.
Example: conservation of money. The total value of funds held over all accounts remains constant. A transfer moves money but does not create or destroy it. If the database starts with across all accounts, it still has after any valid transaction.
Isolation
The intermediate state of a transaction is invisible to other transactions. As a result, transactions that run concurrently appear to be serialised. Each transaction behaves as if it ran alone on the database.
Example: another concurrent transaction sees the transferred funds in one account or the other, but not in both, nor in neither. It never observes the moment when money has left the source account but not yet arrived at the destination.
Durability
After a transaction successfully completes (commits), changes to data persist and are not undone, even in the event of a system failure. The DBMS typically achieves this through write-ahead logging: changes are written to a persistent log before being applied to the database files.
Implementation note
Implementing ACID transactions is lectured in Part IB Concurrent and Distributed Systems. The mechanisms (locking, logging, two-phase commit) are not part of this course.
Summary
| Property | Key guarantee |
|---|---|
| Atomicity | All or nothing |
| Consistency | Valid state preserved |
| Isolation | Non-interference between concurrent transactions |
| Durability | Survives crashes |