Distributed Database Management Systems: Lecture 26. The main topics covered in this chapter include: transaction management with basics and properties of transaction; database consistency; a transaction is a logical unit of work; consistent transaction;...
Trang 1Distributed Database Management Systems
Lecture 26
Trang 2In this Lecture
• Transaction Management
–Basics
–Properties of Transaction
Trang 3• Database consistency
• A transaction is a
logical unit of work
• Consistent transaction.
Trang 4Consistent State
Execution of Transaction T
End of Transaction T
Trang 5Transaction
Management is
difficult in case of the concurrent access to the database by
multiple users.
Trang 7A transaction is
considered to be a
sequence of read or/and write operations; it may even consist of a single statement
Trang 8Transaction Example T-SQL
Transaction BUDGET_UPDATE
begin
EXEC SQL UPDATE J SET BUDGET = BUDGET * 1.1 WHERE JNAME = “CAD/CAM" end
Trang 9Example Database
Airline Reservation System– FLIGHT(fNo, fDate, fSrc, fDest,
stSold, fCap)
– CUST(cName, cAddr, cBal)
– FC(fNo, fDate, cName, cSpecial)
Trang 10Begin_transaction Reservation
EXEC SQL Select stSold, cap into temp1, temp2
where fNo = flight_no and date = dt
output("no free seats"); Abort else
EXEC SQL update flight
EXEC SQL insert into FC values (flight_no,
dt, c_Name, null); Commit;
output("reservation completed")
end
Trang 12- Read and Write are
major operations of DB concern in a transaction
- Read set (RS): The set
of data items that are
read by a transaction
Trang 13- Write set (WS): The set of
data items whose values
are changed by this
transaction
- Base set (BS) = RS U WS
- RS and WS need not to be
mutually exclusive
Trang 14• Above Characterizations
are simple since they do
not consider insert and
delete, so concern more a static DB
• Dynamic Trs have to deal
with Phantoms
Trang 15Let O ij(x) be some operation
Trang 18Conflicting Operations
Two operations Oi(x) and
Oj(x) are said to be in
conflict, Oi = write or Oj = write (at least one of them
is write and they access
the same data item)
Trang 21ACID Properties of a
Transaction
Trang 221- Atomicity: also known
as “all or none” property
–refers to the atomicity of
entire Tr rather than an
individual operation
–It requires from system to
define some action in case of any interruption in execution
of Tr.
Trang 23–Two types of failures requiring
procedures from Transaction
Recovery or Crash Recovery
2- Consistency: refers simply
to the correctness of a
transaction
–A Transaction should transform
the DB from one consistent
state to another consistent
state.
Trang 24by a Transaction before its commitment.
Trang 25• Degree 3 Consistency
1- T does not overwrite dirty data of other Transaction
2- T does not commit any writes until
it completes all its writes (i.e., until end of Transaction)
3- T does not read dirty data from
other Transaction
4- Other Transaction do not dirty any data read by T before T commits
Trang 263- Isolation
- A Transaction cannot reveal its
results to other Transaction
before commitment
- Required in particular when
one of the Transaction is
updating a common data item
Trang 27- Consider two Trs T1 and T2
Trang 29Thanks