Detailed Transaction Processing Notes
Detailed Transaction Processing Notes
Processing in DBMS
1. Introduction to Transaction Processing
Transaction processing is a crucial functionality of Database Management Systems
(DBMS) that ensures the reliability of operations performed on a database. It allows
multiple operations to be bundled into a single transaction which is executed as one
unit. If any of the operations fail, the entire transaction is rolled back to maintain
consistency.
Use Cases:
- Banking systems: Transferring funds from one account to another.
- Online shopping: Placing an order and reducing inventory.
- Airline reservations: Booking and updating available seats.
2. What is a Transaction?
A transaction is a sequence of one or more SQL operations that perform a logical
unit of work. Transactions must exhibit the ACID properties to ensure database
integrity, especially in multi-user environments.
3. System Concepts
Transaction processing involves several components and states:
Components:
- Concurrency Control Manager: Manages simultaneous transaction execution to
avoid conflicts.
- Recovery Manager: Restores the database to a consistent state in case of failure.
Transaction States:
- Active: Transaction is being executed.
- Partially Committed: Last operation executed, awaiting commit.
- Committed: All operations completed successfully.
- Failed: An error has occurred during transaction.
- Aborted: Transaction is rolled back due to a failure.
5. Recoverability in Schedules
Schedules are the sequences in which transactions' operations are executed.
Recoverability ensures that the database can be restored to a consistent state after a
crash.
Types:
- Recoverable Schedules: A transaction commits only after the transactions it
depends on have committed.
- Cascadeless Schedules: Transactions only read data written by committed
transactions, preventing cascading rollbacks.
- Strict Schedules: Transactions cannot read or write data modified by another
uncommitted transaction.
6. Serializability of Schedules
Serializability is the main criterion for correctness in concurrent transactions. It
ensures the result of concurrent execution is the same as if the transactions were
executed serially.
Types of Serializability:
- Conflict Serializability: Determined by analyzing conflicting operations
(read/write).
- View Serializability: Based on the view of transactions and final results. More
complex to test.
Example:
BEGIN TRANSACTION;
UPDATE accounts SET balance = balance - 100 WHERE id = 'A';
UPDATE accounts SET balance = balance + 100 WHERE id = 'B';
COMMIT;
9. Summary
Transaction processing is essential for reliable database systems. Key points
include:
- A transaction is a logical unit of work.
- ACID properties ensure reliability.
- Schedules must be recoverable and serializable.
- SQL offers transaction control mechanisms for managing consistency and rollback.