This is an PPT of DBMS. It include the topics such as"Transaction Processing its properties & States "
Size: 1.12 MB
Language: en
Added: Apr 08, 2020
Slides: 22 pages
Slide Content
BIRLA INSTITUTE OF TECHNOLOGY,MESRA RANCHI JAIPUR CAMPUS Presentation on: “Transaction Processing, its properties and states ” Presented By: Deepshikha Haritwal (MCA/25001/18) Roopak Bhama (MCA/25003/18)
Contents Introduction to transactions Transaction Control Properties of transactions States of transactions
What is a Transaction? A transaction is a basic unit of program execution which possibly access and update various data items in a database. Collection of operations that form a single logical unit of work are called transactions.
A transaction is delimited by statements of the form begin transaction and end transaction. The transaction consists of all operations executed between the begin transaction and end transaction.
Example of Transaction A withdrawal transaction in an ATM could consist of following steps: Verify account details Accept withdrawal request Check balance Update balance Dispense money
Transaction control The following commands are used to control transactions. COMMIT − to save the changes. ROLLBACK − to roll back the changes. SAVEPOINT − creates points within the groups of transactions in which to ROLLBACK. SET TRANSACTION − Places a name on a transaction.
Commit command The commit command is the transactional command used to save changes invoked by a transaction to the database. The syntax for the commit command is as follows: COMMIT; Example : sql ?>DELETE FROM CUSTOMERS WHERE AGE = 25; sql > COMMIT;
Rollback command The rollback command is the transactional command used to undo transactions that have not already been saved to the database. The syntax for a rollback command is − ROLLBACK; Example : SQL> DELETE FROM CUSTOMERS WHERE AGE = 25; SQL> ROLLBACK;
Savepoint command A savepoint is a point in a transaction when you can roll the transaction back to a certain point without rolling back the entire transaction. The syntax for a savepoint command is: SAVEPOINT SAVEPOINT_NAME;
Set transaction command The set transaction command can be used to initiate a database transaction. For example we can specify a transaction to be read only or read write. The syntax for a set transaction command is: SET TRANSACTION [ READ WRITE | READ ONLY ];
Properties of Transactions In order to maintain consistency in a database, before and after transaction, certain properties are followed. These are called ACID properties. A: Atomicity C: Consistency I: Isolation D: Durability
Atomicity It means that the entire transaction takes place at once or doesn’t happen at all. There is no midway i.e. transactions do not occur partially.
It involves following two operations. Abort : If a transaction aborts, changes made to database are not visible. Commit : If a transaction commits, changes made are visible. Atomicity is also known as the ‘All or nothing rule’.
Consistency This means that integrity constraints must be maintained so that the database is consistent before and after the transaction. It refers to correctness of a database.
Isolation This property ensures that multiple transactions can occur concurrently without leading to inconsistency of database state. Transactions occur independently without interference. Changes occurring in a particular transaction will not be visible to any other transaction until that particular change in that transaction is written to memory or has been committed.
Durability This property ensures that once the transaction has completed execution, the updates and modifications to the database are stored in and written to disk. These updates now become permanent and are stored in a non-volatile memory. The effects of the transaction, thus, are never lost.
Transaction States While the transaction executes in a database it could be in one of the following states: Active : In this state, the transaction is being executed. This is the initial state of every transaction. Partially committed: When a transaction executes its final operation, it is said to be in a partially committed state.
Failed : A transaction is said to be in a failed state if any of the checks made by the database recovery system fails. A failed transaction can no longer proceed further. Aborted: If any of the checks fails and the transaction has reached a failed state, then the recovery manager rolls back all its write operations on the database to bring the database back to its original state where it was prior to the execution of the transaction. Transactions in this state are called aborted. Committed: If a transaction executes all its operations successfully, it is said to be committed. All its effects are now permanently established on the database system
Demonstrating transaction states Consider a user making a booking for a flight over a web. While the user is selecting the time for departure and the seat available, the transaction is said to be in active state. When the user is making the payment for the tickets, the transaction is said to be partially commited .
While making the payment if the system crashes or network connection goes off, the transaction may be aborted. Otherwise, if successful payment is made the transaction is said to be committed.