A database transaction is an indivisible unit of work that groups multiple operations into one logical step. It protects data when operations must succeed together, such as deducting money from one account and adding it to another. section 6.5 section 6.1.1
Transactions are commonly understood through four ACID properties and a short operational lifecycle:
- Atomicity makes the work all-or-nothing: if one operation fails, the transaction rolls back rather than leaving partial changes. section 6.1.1
- Consistency requires each accepted transaction to preserve database integrity rules, such as foreign-key constraints and valid data types. section 6.1.1
- Isolation limits the effect of concurrent transactions; isolation levels determine how strictly this property is enforced. section 6.5
- Durability makes committed changes permanent, while rollback undoes changes that were not committed. section 6.5
- The lifecycle is begin, perform reads or writes, then commit or roll back. A savepoint can provide an intermediate rollback target during complex work. section 6.5
Bank transfer
Treat subtracting funds from one account and adding them to another as one transaction. If either operation fails, roll back both changes; otherwise, commit them together. section 6.1.1
Transactions protect structural data integrity but do not automatically enforce every business invariant. For example, keeping the sum of customer balances positive may require application-level logic. Atomicity can also span a database write and a Kafka message, making the guarantee a property of the wider system. section 6.1.1 section 6.5




















