Transactions Flashcards
What is a database transaction?
A unit of program execution that accesses and possibly updates various data items delimited by begin transaction and end transaction statements
What does the ACID acronym stand for in database transactions?
Atomicity Consistency Isolation Durability
What is atomicity in database transactions?
Either all operations of the transaction are reflected in the database or none are
What is consistency in database transactions?
The database remains in a consistent state before and after transaction execution
What is isolation in database transactions?
Each transaction appears to execute alone even when multiple transactions run concurrently
What is durability in database transactions?
Once a transaction completes successfully its changes persist even if system failures occur
What are the two basic operations transactions use to access data?
read(X) and write(X)
What are the five possible states of a transaction?
Active Partially committed Failed Aborted Committed
What happens in the partially committed state?
Final statement executed but transaction may still need to be aborted as data might still be in main memory
What is conflict serializability?
A schedule that can be transformed into a serial schedule by swapping non-conflicting operations
When do two operations conflict in a transaction schedule?
When they are from different transactions operate on same data item and at least one is a write operation
How can you determine if a schedule is conflict serializable?
Create a precedence graph - if it has no cycles the schedule is conflict serializable
What is a recoverable schedule?
One where transactions commit only after all transactions whose changes they read have committed
What is a cascadeless schedule?
One where transactions only read data written by committed transactions
What are the three main implementation techniques for transaction isolation?
Locking Timestamp ordering and Versioning