DBMS Assignment 
-Transaction states 
- ACID properties 
- Concurrency control 
Presented by 
Pranay Guha 
MBA 3rd Semester 
Major-Marketing 
Techno India, Salt 
Lake
Initiate 
Transaction 
Flowchart of Transaction States 
Begin 
Read, write 
Active 
End 
Transaction 
Partially 
Committed 
Commi 
t Committed 
Failed 
Abort 
Terminated 
Abort
States for Transaction Execution 
 Active State – A transaction enters into an active state immediately after it start 
its execution where it can issue read or write operations. 
 Partially Committed – A transaction goes into partially committed state after the 
end of a transaction and at this point, some recovery protocol is needed. 
 Committed State – Once the transaction is committed, it has concluded its 
execution successfully and all of its changes are recorded to the database 
permanently. 
 Failed State – A transaction goes to the failed state if any one of the check fails 
or if the transaction is aborted during its active state. 
 Terminated State – This state corresponds to the transaction leaving the 
system. The failed or aborted transactions may have restarted later either 
automatically or after being resubmitted by the user.
ACID 
Properties  Atomicity – The atomicity property ensures the completion of the transaction 
execution. It is the responsibility of the recovery subsystem of the database 
management system. 
 Consistency – Transaction preserves database consistency. It is the responsibility 
of the programmer who writes the database program or the DBMS modules who 
enforce the integrity constraints. 
 Isolation – If every transaction does not make its update visible to other 
transactions until it is committed, it solves the temporary update problem and 
eliminates cascading rollback. It defines different levels of isolation:- 
1) Level 0. 
2) Level 1. 
3) Level 2. 
4) Level 3. 
 Durability – Once the transaction commits, its update survive even after the 
subsequent system crash. It is the responsibility of the recovery subsystem of the 
database management system.
Concurrency 
Control 
Isolation (+ Consistency) => Concurrency 
Control 
 Concurrency means allowing more than one transaction to run simultaneously on 
the same database. 
 When several transactions run concurrently database consistency can be destroyed. 
 It is meant to coordinate simultaneous transactions while preserving data 
integrity. 
 It is about to control the multi-user access of database. 
To illustrate the concept of concurrency control, consider two travellers who go to electronic 
kiosks at the same time to purchase a train ticket to the same destination on the same train. 
There's only one seat left in the coach, but without concurrency control, it's possible that 
both travellers will end up purchasing a ticket for that one seat. However, with concurrency 
control, the database wouldn't allow this to happen. Both travellers would still be able to 
access the train seating database, but concurrency control would preserve data accuracy 
and allow only one traveller to purchase the seat. 
This example also illustrates the importance of addressing this issue in a multi-user 
database.
Why concurrency control is necessary ? 
 The Lost Update Problem 
T1 T2 
read_item(X); 
X:= X+10; 
write_item(X); 
commit; 
read_item(X); 
X:= X+20; 
write_item(X); 
commit; 
Lost 
update 
State of X 
20 
20 
40 
30 
 Changes of T2 are lost.
Why concurrency control is necessary ? (Contd.) 
 The Temporary Update/ Dirty Read Problem 
T1 T2 
read_item(X); 
X:= X+10; 
write_item(X); 
X:=X+10; 
write_item(X); 
commit; 
Dirty update 
read_ item(X); 
sum:= sum+X; 
write_item(sum); 
commit; 
State of X sum 
20 
30 
40 
0 
30 
 T2 sees dirty data of T1.
Why concurrency control is necessary ? (Contd.) 
 The Incorrect Summary Problem 
T1 T2 
read_item(X); 
X:= X-10; 
write_item(X); 
commit; 
read_item(Y); 
Y:= Y+10; 
write_item(Y); 
commit; 
read_item(A); 
sum:= sum+A; 
write_item(A); 
commit; 
read_item(X); 
sum:= sum+X; 
read_item(Y); 
sum:= sum+Y; 
State of X State of Y 
Incorrect summary 
30 
20 
10 
10 
20 
Let A=100 
sum 
0 
100 
 T2 reads X after 10 is subtracted and reads Y before 10 is added, hence incorrect 
summary.
Why concurrency control is necessary ? (Contd.) 
 The Unrepeatable Read Problem 
T1 T2 
read_item(X); 
read_item(X); 
X:= X+10; 
write_item(X); 
commit; 
read_item(X); 
X:= X+20; 
write_item(X); 
commit; 
State of X 
20 
20 
40 
40 
Unrepeata 
ble read 
 T1 reads different values for X.
Advanced DBMS presentation

Advanced DBMS presentation

  • 1.
    DBMS Assignment -Transactionstates - ACID properties - Concurrency control Presented by Pranay Guha MBA 3rd Semester Major-Marketing Techno India, Salt Lake
  • 2.
    Initiate Transaction Flowchartof Transaction States Begin Read, write Active End Transaction Partially Committed Commi t Committed Failed Abort Terminated Abort
  • 3.
    States for TransactionExecution  Active State – A transaction enters into an active state immediately after it start its execution where it can issue read or write operations.  Partially Committed – A transaction goes into partially committed state after the end of a transaction and at this point, some recovery protocol is needed.  Committed State – Once the transaction is committed, it has concluded its execution successfully and all of its changes are recorded to the database permanently.  Failed State – A transaction goes to the failed state if any one of the check fails or if the transaction is aborted during its active state.  Terminated State – This state corresponds to the transaction leaving the system. The failed or aborted transactions may have restarted later either automatically or after being resubmitted by the user.
  • 4.
    ACID Properties Atomicity – The atomicity property ensures the completion of the transaction execution. It is the responsibility of the recovery subsystem of the database management system.  Consistency – Transaction preserves database consistency. It is the responsibility of the programmer who writes the database program or the DBMS modules who enforce the integrity constraints.  Isolation – If every transaction does not make its update visible to other transactions until it is committed, it solves the temporary update problem and eliminates cascading rollback. It defines different levels of isolation:- 1) Level 0. 2) Level 1. 3) Level 2. 4) Level 3.  Durability – Once the transaction commits, its update survive even after the subsequent system crash. It is the responsibility of the recovery subsystem of the database management system.
  • 5.
    Concurrency Control Isolation(+ Consistency) => Concurrency Control  Concurrency means allowing more than one transaction to run simultaneously on the same database.  When several transactions run concurrently database consistency can be destroyed.  It is meant to coordinate simultaneous transactions while preserving data integrity.  It is about to control the multi-user access of database. To illustrate the concept of concurrency control, consider two travellers who go to electronic kiosks at the same time to purchase a train ticket to the same destination on the same train. There's only one seat left in the coach, but without concurrency control, it's possible that both travellers will end up purchasing a ticket for that one seat. However, with concurrency control, the database wouldn't allow this to happen. Both travellers would still be able to access the train seating database, but concurrency control would preserve data accuracy and allow only one traveller to purchase the seat. This example also illustrates the importance of addressing this issue in a multi-user database.
  • 6.
    Why concurrency controlis necessary ?  The Lost Update Problem T1 T2 read_item(X); X:= X+10; write_item(X); commit; read_item(X); X:= X+20; write_item(X); commit; Lost update State of X 20 20 40 30  Changes of T2 are lost.
  • 7.
    Why concurrency controlis necessary ? (Contd.)  The Temporary Update/ Dirty Read Problem T1 T2 read_item(X); X:= X+10; write_item(X); X:=X+10; write_item(X); commit; Dirty update read_ item(X); sum:= sum+X; write_item(sum); commit; State of X sum 20 30 40 0 30  T2 sees dirty data of T1.
  • 8.
    Why concurrency controlis necessary ? (Contd.)  The Incorrect Summary Problem T1 T2 read_item(X); X:= X-10; write_item(X); commit; read_item(Y); Y:= Y+10; write_item(Y); commit; read_item(A); sum:= sum+A; write_item(A); commit; read_item(X); sum:= sum+X; read_item(Y); sum:= sum+Y; State of X State of Y Incorrect summary 30 20 10 10 20 Let A=100 sum 0 100  T2 reads X after 10 is subtracted and reads Y before 10 is added, hence incorrect summary.
  • 9.
    Why concurrency controlis necessary ? (Contd.)  The Unrepeatable Read Problem T1 T2 read_item(X); read_item(X); X:= X+10; write_item(X); commit; read_item(X); X:= X+20; write_item(X); commit; State of X 20 20 40 40 Unrepeata ble read  T1 reads different values for X.