Svar till transaktionsövningen (Databasteknik II)

At the start, the data item A has the value 100, and B has the value 200.

Exercise 1. What is the state of the database after the two transactions?

Answer: A=10, B=200

Exercise 2. In another serial schedule, transaction T2 is run first, and then T1. What is the state of the database after the two transactions?

Answer: A=100, B=10

Exercise 3. No transaction management is used to isolate the transactions from each other. What is the state of the database after the two transactions?

Answer: A=10, B=100

Exercise 4. Assume that basic two-phase locking with simple exclusive locks are used. Show how locks are requested, how the transactions will have to wait for locks, and how the read and write operations in the schedule are re-ordered.

Answer: First all operations in T1 will be done, then all in T2.

Exercise 5. Assume that two-phase locking with two-state locks (shared read locks and exclusive write locks) are used. Assume that a transaction doesn't request an exclusive lock on a data item until it actually wants to write that item. Show what happens.

Answer: Deadlock.

Exercise 6. Assume that the basic timestamp method, as described in Elmasri/Navathe 3d Ed section 20.2 (pp 672-674) is used, with Thomas's Write Rule. Show how the timestamps of the data items A and B will be affected. If one or both transactions are aborted, show when and how, and explain why it had to be done. Also, explain why Thomas's Write Rule works.

Partial answer: T1 is aborted in step 8. T2 is completed.

Exercise 7. Assume that timestamps are used, as in the exercise above, but step 8 says Read(A) instead of Write(A) What happens?

Answer: Both transactions are completed.

Exercise 8. Assume that an optimistic method, as described in Elmasri/Navathe 3d Ed section 20.4 (pp 677-678) is used. Show what happens. If one or both transactions are aborted, show when and how, and explain why it had to be done.

Partial answer: This depends on exactly when the validation and write phases begin and end. Usually T1's validation fails, and it has to be aborted.


Thomas Padron-McCarthy (thomas.padron-mccarthy@tech.oru.se), 5 februari 2007