You are on page 1of 5

Transaction

Dr. Engr. Sami ur Rahman


Transaction

 A transaction is defined as a logical unit work.


 It consist of one or more operations on a database that must be
completed together so that the database remains in a consistent state.
 A transaction must either complete successfully or fail.

Stock Sold
item list items list

 After selling an item, it must be added in the sold items list (one
operation) and it should be subtracted from the stock items list (second
operation).
 Both of these operations together make up a single transcation.
 Both must complete successfully or both mus fail.
University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman 2 of 6
Commit and Rollback

 A transaction is committed if it completes successfully and changes the


data.
 If it fails and leaves the data unchanged, it is said that the transaction
has been rolled back.
 The rollback is used to undo the work done in the current transaction.

University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman 3 of 6
Transaction Properties (ACID Properties)

 If programmers guarantee correctness of individual transactions, then


DBMS guarantees correctness of any set of them
 A transaction must have four properties called ACID (Atomicity,
Consistency, Isolation, Durability) properties.
 (Failure) Atomicity: A transaction must completely succeed or
completely fail.
 Consistency: A transaction must leave the data in consistent state after
completion. For example, in a bank database, money should never be
created or deleted without an appropriate deposit or withdrawal.
 Isolation: All transaction that modify the data are isolated from each
other. They do not access the same data at the same time. Transaction
must have no dependence or effect on other transactions.
 Durability—The modification made by a transaction are permanent and
persistent. If the same is crashed or rebooted, data should be
guaranteed to be completed when the computer restarts.

University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman 4 of 6
Thanks for your attention

University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman 5 of 6

You might also like