Labs 6 - Multiple granularity, timestamp, and validation-based protocols. ========================================================================= Exercises ========= (1) The operations of transactions T1, T2, T3 arrive at the scheduler in the order shown on the following schedule. Simulate a timestamp-based scheduler and insert aborts when required. T1: T2: T3: read(X) read(Y) read(X) read(X) write(X) write(Y) write(X) read(Y) (2) Consider a timestamp-based scheduler and transactions T1, T2, TS(T1)=3, TS(T2)=4. Furthermore, assume that the data items X and Y have last been read and written by a transaction with timestamp 1. Describe each step taken by the timestamp-based scheduler. T1: T2: read(X) read(Y) read(Y) read(X) write(Y) write(X) (3) Is the following schedule possible under a timestamp-based ordering protocol? (TS(T1)=1, TS(T2)=2, TS(T3)=3) T1: T2: T3: read(Z) read(Y) write(Y) read(Y) read(Z) read(X) write(X) write(Y) write(Z) read(X) read(Y) write(Y) write(X) (4) A database has two (R)elations, each relation has two (T)uples, and each tuple has two (A)ttributes. Draw the database elements in a hierarchy. Assuming that no locks are released, indicate the locks acquired by each of the following transactions executed in the given order. T1: Update A1 of T1 of R1. T2: Update A2 for all tuples in R2. T3: Read all tuples of R1. (5) Consider the database with the following two relations: (M)ovies[mid, title, year, avg_rating] (A)ctors[mid, name] Organize the database elements in a hierarchy. For each of the following queries, indicate the sequence of lock and unlock operations issued by a transaction executing a single query. Q1: Change the tiles of all movies to capital letters. Q2: What is the rating of the movie "Minions"? Q3: List all the actors. Q4: Compute the average rating of all movies published in 2014. Q5: Reset the ratings of all movies filmed in 2000. (6) Consider the following two schedules. Indicate what happens when each schedule is processed by a validation-based scheduler. Schedule 1 -------------------------------- T1: T2: T3: read(A,B) read(B,C) read(C) validate validate validate write(A) write(B) write(C) Schedule 2 -------------------------------- T1: T2: T3: read(A,B) read(B,C) read(B) validate validate write(C) validate write(B) write(C)