



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




The slides are based on the textbook Database Systems by Thomas Connolly & Carolyn Begg
30/05/2007 DBDI / CocnCntrl 2
30/05/2007 DBDI / CocnCntrl 3
Database Integrity
}
30/05/2007 DBDI / CocnCntrl 4
Properties of Transactions
All or nothing; indivisible unit
Database should stay in a consistent state.
independent execution of other transactions.
Permanent effects of update.
A C I D
Transactions Management
Scenario:
transferring money from one account to another in one bank requires the SQL commands:
Transaction integrity
30/05/2007 DBDI / CocnCntrl 7
permanent
have not been committed will be lost
Commit/Rollback protocol
explicit commit command when both of these update commands have been
issued
30/05/2007 DBDI / CocnCntrl 8
Update in 2
Commit/Rollback Protocol /
30/05/2007 DBDI / CocnCntrl 9
Commit/Rollback Protocol /
30/05/2007 DBDI / CocnCntrl 10
Checkpoints
Database T1 T Example:
N= 5; M= 3
Is it Serial
Schedule?
Time
Valid Concurrent Transaction / Example 2
Database T1 T Example:
N= 5; M= 3
Is it Serial
Schedule?
Example 1 & 2
are Equivalent
Schedules
Time
30/05/2007 DBDI / CocnCntrl 19
Inconsistent Analysis
Balance = 0
TA {Select Sum (Balance) From Account;}
TB {Update Accounts Set Balance = Balance - 100 Where Accno = 3; Update Accounts Set Balance = Balance + 100 Where Accno = 1;}
Retrieves account 3 Balance = 100
Retrieves account 1 Balance = 100
Retrieves Account 1 Balance = 100 Total = 100
Retrieves Account 2 Balance = 100 Total = 200
Balance = 0 Total = 200
Balance = 100 Total = 300
Retrieves Account 4
Updates account 1^ Balance = 200
30/05/2007 DBDI / CocnCntrl 20
Temporary Update / Case 1
100 undo
abort
Database T1 T Example:
N= 5; M= 3
This scenario
is ok.
T1's effects
have been
eliminated.
Time
30/05/2007 DBDI / CocnCntrl 21
Temporary Update / Case 2
100 undo
abort
Database T1 T Example:
N= 5; M= 3
some of T1's
effects have
been retained!
Time
30/05/2007 DBDI / CocnCntrl 22
Temporary Update / Case 3
100 undo
abort
Database T1 T Example:
N= 5; M= 3
T2's effects
have been
lost, even after
commit!
What is this
problem?
Time
Locking
transactions
finishes with it
object is released
30/05/2007 DBDI / CocnCntrl 25
30/05/2007 DBDI / CocnCntrl 26
30/05/2007 DBDI / CocnCntrl 27
Release S on Obj
Place S on Obj
Place S on Obj
Place S on Obj
Place X on Obj
Release S on Obj
Release X on Obj1 Place S on Obj
Place X on Obj
Release S on Obj
Release X on Obj
TA: S lock on Obj1; S on Obj2; X on Obj
TB: S lock on Obj1; X on Obj1; S on Obj
Place X on Obj
Denied, Wait for X on Obj
30/05/2007 DBDI / CocnCntrl 28
Place X on Obj
Place X on Obj
Place S on Obj
Place X on Obj
Release all locks^ Wait
Place S on Obj
TA: S lock on Obj1; S on Obj2; X on Obj
TB: S lock on Obj1; X on Obj1; S on Obj
Release all locks
Request X not S Requests denied, Wait
Wait