A transaction is initiated by a user program written in a high level language or programming language. (e.g.: java, COBOL, C, C++...). The transaction is delimited by statements of the form begin transaction and end transaction. The transactions of all operations which appear between these two statements.
Consider the following example of transferring Rs. 500 from account A to account B. This transaction can be defined as
- Read (A);
- A: = A-500;
- Write (A);
- Read (B);
- B: = B+500;
- Write (B);
- A transaction would always be present in one of the following states:
- Active state, this is the initial state of the transaction and it stays in this state while it is executing
- Partially committed, A transaction is partially committed when the final statement is executed
- Failed, this is the state when normal execution is interrupted and can no longer proceed.
- Aborted, the state after the transaction has been rolled back and database is restored to the state prior to start of the transaction. There are two actions to be taken after the transaction is aborted, either restart the transaction or kill the transaction.
- Committed, the state when transaction is successfully completed.
The transaction management subsystem of dbms generally consists of,
- Transaction Manager: This coordinates transactions on behalf of application program and communicates with scheduler.
- Scheduler: This implements a strategy of concurrency control.
- Recovery Manager: recovery handles failure and helps to maintain consistency
- Buffer Manager: It takes care of transferring data between disk storage and main memo
- File Manager: this manipulates the underlying files and manages the allocation of space on disk.
- Access Manager: The requests are sent from file manager to access manager to manage the input and output data.
- System manager: An appropriate method to read or write data through system manager.