Unit 1: Transaction management
Database Management Systems-II notes · PTU syllabus (UGCC2523)
On this page
Unit summary
When many users read and update a database at the same time, the DBMS must keep data correct. This unit covers transactions and their ACID properties, schedules, serializability and recoverability, lock-based concurrency control including two-phase locking, deadlock handling, transaction support in SQL and crash recovery.
After this unit you can
- Define a transaction and explain the ACID properties
- Explain schedules, conflict serializability and recoverability
- Apply lock-based concurrency control and two-phase locking
- Handle deadlocks and explain crash recovery
PTU syllabus topics
- ACID properties
- transactions and schedules
- concurrent execution
- lock-based concurrency control
- performance of locking
- transaction support in SQL
- crash recovery
- 2PL
- serializability and recoverability
- lock management
- deadlock handling
Atomicity
All or nothing
Consistency
Valid state before and after
Isolation
Transactions do not interfere
Durability
Committed data survives failures
Topic 1
Transactions and ACID
A transaction is a sequence of operations performed as a single logical unit of work (for example transferring ₹500 from account A to B).
Atomicity
All operations happen, or none
Consistency
Takes the database from one valid state to another
Isolation
Concurrent transactions don't interfere
Durability
Committed changes survive failures
Transaction states: active → partially committed → committed, or active → failed → aborted.
Topic 2
Schedules, serializability and recoverability
A schedule is the order in which operations of concurrent transactions are executed. A serial schedule runs transactions one after another; a concurrent schedule interleaves them.
- A schedule is conflict serializable if it can be transformed into a serial schedule by swapping non-conflicting operations. Test: draw a precedence graph; if it has no cycle, the schedule is serializable.
- Two operations conflict if they belong to different transactions, access the same item, and at least one is a write.
- A recoverable schedule commits a transaction only after every transaction it read from has committed. A cascadeless schedule reads only committed data, avoiding cascading rollbacks.
Problems of uncontrolled concurrency: lost update, dirty read (reading uncommitted data), unrepeatable read and the phantom problem.
Topic 3
Lock-based concurrency control and 2PL
- Shared lock (S): for reading; many transactions can hold it together.
- Exclusive lock (X): for writing; only one transaction can hold it.
Two-phase locking (2PL) guarantees conflict serializability:
- 1Growing phase
Acquire locks, release none
- 2Lock point
All locks held
- 3Shrinking phase
Release locks, acquire none
Strict 2PL holds exclusive locks until commit, preventing cascading rollbacks. A lock manager keeps a lock table of granted and waiting requests. Locking has an overhead: more locking reduces concurrency and throughput.
Topic 4
Deadlock handling
A deadlock occurs when transactions wait for each other's locks in a cycle. Methods:
- Prevention: wait-die and wound-wait schemes based on timestamps.
- Detection: build a wait-for graph; a cycle means deadlock; then abort a victim transaction.
- Timeouts: abort a transaction that waits too long.
Topic 5
Transaction support in SQL and crash recovery
SQL controls transactions with BEGIN/START TRANSACTION, COMMIT, ROLLBACK and SAVEPOINT, and sets isolation levels: READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ, SERIALIZABLE. Crash recovery uses a log of all changes (write-ahead logging: log first, then data). After a crash, the system redoes committed transactions and undoes uncommitted ones. Checkpoints limit how much of the log must be scanned. The ARIES algorithm performs analysis, redo and undo phases.
Key terms
- Transaction
- A logical unit of database work
- Serializability
- Equivalence of a concurrent schedule to a serial one
- Two-phase locking
- Locks acquired in a growing phase and released in a shrinking phase
- Wait-for graph
- A graph used to detect deadlocks
- Write-ahead logging
- Writing log records before data changes
Quick revision
- ACID: atomicity, consistency, isolation, durability.
- Precedence graph without a cycle = conflict serializable.
- S lock shared; X lock exclusive.
- 2PL: growing then shrinking; strict 2PL holds X locks till commit.
- Recovery: redo committed, undo uncommitted.
Important exam questions
Practice questions written to the PTU exam pattern for this unit's syllabus: short answers (Section A style) and long answers (Sections B and C style).
Short-answer questions
- Q1.Define a transaction and state the ACID properties.
- Q2.What is a dirty read?
- Q3.When are two operations conflicting?
- Q4.Explain the two phases of 2PL.
- Q5.What is a wait-for graph?
- Q6.What is a checkpoint?
Long-answer questions
- Q1.Explain the ACID properties with a bank transfer example.
- Q2.Explain conflict serializability and test a schedule using a precedence graph.
- Q3.Explain lock-based concurrency control and two-phase locking.
- Q4.Explain log-based crash recovery with checkpoints.
Stuck on this unit?
Message SBS on WhatsApp for help with Database Management Systems-II, or to ask about studying BCA at Synetic.
