Transaction¶
A transaction is a bunch of instructions that are clubbed together. The defining attribute of a transaction is that it's performed either completely or not at all. It may update items in the database.
ACID Requirements¶
Atomicity¶
- Come all, or come none.
- The transaction is either completed fully, or aborted.
Consistency¶
- Constraints maintain their truthfulness before and after a transaction.
- This includes explicit integrity constraints like foreign keys, as well as implicit integrity constraints (consider the sum of money in A and B after a fund transfer between the two).
- The database may be inconsistent during a transaction.
Isolation¶
- Result of a set of transactions done concurrently must be the same as the result of serial execution.
- Each transaction must behave as if it is unaware of concurrently existing transactions.
Durability¶
- The database must be able to restore even if there is a failure, such as a system failure or a software failure.