What We Learn in This Presentation
What We Learn in This Presentation
What We Learn in This Presentation
Reference:
o Database Systems by Thomas Connolly [6th Edition]
o Principles of Distributed Database Systems by M. Tamer [3rd Edition]
o Database Management Systems by Ramakrishnan [3rd Edition]
o Introduction To Transaction Management [Slides] by Arturas Mazeika
o http://ecomputernotes.com/database-system/rdbms/transaction
Transaction
Processing System
TRANSACTION
It is a single SQL statement that does Select, Update, Insert or Delete of rows.
QUERY It is not necessary that data modification to be made permanent in database.
It means that transaction is successfully executed and all the data modifications become the permanent
COMMIT part of the database.
ABORT It means that transaction is not successfully executed and all the data modifications are erased.
ACID Properties of TRANSACTION
A transaction is a single unit of operation that is either executed entirely or none of
ATOMICITY the statement of transaction is executed. It is also called “All or Nothing” property.
A transaction must transform the database from one consistent state to another
CONSISTENCY consistent state. It means that transaction must be correct and data integrity should
be maintained.
A transaction with very short execution/response times and access relatively small
Short-Life portion of the database. It is also called Online Transaction.
Examples: Banking transactions, Airline Reservation Transactions, etc.
A transaction with longer execution/response times and access a larger portion of the
Long-Life database. It is also called Batch Transaction.
Examples: Statistical Applications, Image Processing, etc.
Types of TRANSACTION
( II. Organization Read & Write Action )
A transaction in which order of read and write action is not specified.
General T : {R(x), W(z), R(y), W(y), W(x), C}
A transaction in which all read actions are performed before any write action.
Two-Step T : {R(x), R(y), W(y), W(x), W(z) C}
A transaction in which restriction is applied that a data item cannot be updated until it
Restricted is read. T : {R(x), R(y), W(y), W(x), R(z), W(z) C}
A transaction which includes other transactions with their own start and end point.
Begin_Transaction ABC begin Begin_Transaction XYZ begin . . . end end
Nested
Closed-Nested : Sub-transactions begin after their parent and finish before them.
Open-Nested : Sub-transactions can execute and commit independently
It means that transaction is not successfully executed and all the data modifications
Abort are erased.
States of TRANSACTION
Active An initial state where transactions stay while it is executing.
Partially
A state which occurs after the execution of final statement of transaction.
Committed
Failed A state which occurs when transaction can no longer proceed further.
A state which occurs when the transaction has been rolled back and the database
Aborted has been restored to its state prior to the start of execution.
A transaction must transform the database from one consistent state to another
CONSISTENCY consistent state. It means that transaction must be correct and data integrity should
be maintained.
T1 T2 T1 T2
Read (x) Read (x) Read (x)
Write (x) Write (x) Write (x)
Read (x)
Write (x)
Schedule & Conflicts
T1
T2
Read (x)
Write (x) Read (x)
Read (y) Write (x)
Serial Schedule: T1 T2
A schedule where the operations of each transactions Read (x)
are executed consecutively is known as Serial Schedule. Write (x)
Read (y)
Read (x)
Write (x)
Non-Serial Schedule: T1 T2
A schedule where the operations of each transactions Read (x)
are interleaved is known as Non-Serial Schedule. Write (x)
Read (x)
Read (y)
Write (x)
Schedule & Conflicts
T1 T2 T1 T2 T1 T2
Read (x) Read (x) Read (x)
Write (x) Write (x) Write (x)
Read (x) Read (x) Read (y)
Write (x) Read (y) Read (x)
Read (y) Write (x) Write (x)
Schedule & Conflicts
WR Conflicts
A transaction T2 read a data item X that has been modified by transaction T1 T1 T2
which has not been committed. Such a read is also called Dirty Read. Read (x)
Write (x)
Read (x)
WW Conflicts Write (x)
A transaction T2 change the value of a data item X that has been modified by Read (y)
transaction T1 which has not been committed.
T1 T2
RW Conflicts Read (x)
Read (x)
A transaction T2 change the value of a data item X that has been read by
Write (x)
transaction T1 which has not been committed. Write (x)
Read (y)
Serializability
T1 T2 T1 T2 T1 T2 T1 T2
Read (x) Read (x) Read (x) Read (x)
Write (x) Write (x) Write (x) Write (x)
Read (x) O Read (x) Read (y) Read (x)
Write (x) R Read (y) = Write (y) Write (x)
Read (y) Write (x) Read (x) Read (y)
Write (y) Write (y) Write (x) Write (y)
Read (y) Read (y) Read (y) Read (y)
Write (y) Write (y) Write (y) Write (y)
Serializability
VIEW SERIALIZABILITY or VIEW EQUIVALENCE
A two or more serializable schedules perform similar actions in a similar way with three conditions :
1) In S1 if T(n) reads data item X, then in S2 T(n) must read the data item X.
2) In S1 if T(n) reads data item X that has written by T(m), then in S2 T(n) also read data item X from T(m).
3) In S1 if last write operation was performed on data item X by T(n), then in S2 T(n) also perform the
same write operation.
T1 T2 T1 T2
Read (x) Read (x)
Read (x) Read (x)
Write (x) Write (x)
Read (x) Read (y)
Write (x) Read (x)
Read (y) Write (x)
Read (y) Read (y)
Write (y) Write (y)
Serializability
RESULT SERIALIZABILITY or RESULT EQUIVALENCE
A two or more serializable schedules produce the same results after execution.
This type of serializability is called Result Serializability.
T1 T2 T1 T2
Read (x) Read (x)
Write (x) Write (x)
Read (x) O Read (x)
Write (x) R Read (y)
Read (y) Write (x)
Write (y) Write (y)
Read (y) Read (y)
Write (y) Write (y)