Week 3 - Transactions and Concurrency Flashcards
transactions - What is a schedule?
A schedule is
an organization of the transactions that
interleave the actions of these transactions from a database perspective.
Serial Schedule
schedule that does NOT interleave the actions of different transactions
Equivalent Schedule
For any database state, the effect of executing the first schedule is identical to the effect of executing the second schedule
Serializable Schedule
A schedule that is equivalent to some serial execution of the transactions
Two Schedule are in Conflict equivalent if (2 items)
1) Involve the same actions of the same transactions
2) Every pair of conflicting actions is ordered the same way
Schedule S is conflict serializable if ?
S is conflict equivalent to some serial schedule
What is a conflicting action
A conflicting action is when a transaction is
writing into something and the other transaction wants to read that data item.
Because that might lead to confusion,
might lead to inconsistency
When are two schedules conflict equivalent?
1) If they have the same actions of the same transactions.
2) If they have the same actions of two different transactions but are ordered the same in both schedules.
3) If they have the same actions of the same transactions, and every pair of conflicting actions has the same order in both schedules.
3) If they have the same actions of the same transactions, and every pair of conflicting actions has the same order in both schedules.
Dependency Graph
Has transaction T2 written or read any item that has been last written by transaction T1
(bad banking example)
What is the result of the following database transaction if the initial values of both A and B is 100?
BEGIN
A=A+100A=A+100A=A+100
B=A+100B=A+100B=A+100
END
1) A=200, B=200
2) A=100, B=200
3) A=200, B=100
4) A=200, B=300
4) A=200, B=300
Consider the following two database transactions with initial values of A=500 and B=500:
T1:A=A+100,B=A−100T1: A=A+100, B=A-100T1:A=A+100,B=A−100
T2:A=A∗1.06,B=B∗1.06T2: A=A1.06, B=B1.06T2:A=A∗1.06,B=B∗1.06
Assuming T1 arrives first, what will be the final values of A and B if the two transactions are processed using a serial schedule?
1) A=636, B=568.16
2) A=630, B=561.80
3) A=636, B=530
4) A=630, B=530
3) A=636, B=530
Consider the following two database transactions with initial values of A=500 and B=500:
T1:A=A+100,B=A−100T1: A=A+100, B=A-100T1:A=A+100,B=A−100
T2:A=A∗1.06,B=B∗1.06T2: A=A1.06, B=B1.06T2:A=A∗1.06,B=B∗1.06
Assuming T1 arrives first, what will be the final values of A and B if the database management system interleaves transactions?
1) A=630, B=530
2) A=636, B=568.16
3) A=630, B=561.80
4) A=636, B=530
2) A=636, B=568.16