5. SELECT SUM (x) FROM R; COMMIT Betty\'s transaction is a sequence of inserts:
ID: 3905814 • Letter: 5
Question
5. SELECT SUM (x) FROM R; COMMIT Betty's transaction is a sequence of inserts: INSERT INTO R VALUES (10); INSERT INTO R VALUES (20); INSERT INTO R VALUES (30); COMMIT Carol's transaction is a sequence of deletes: DELETE FROM R WHERE x=30; DELETE FROM R WHERE x=20; COMMIT; Before any of these transactions execute, the sum of the integers in R is 1000, and none of these integers are 10, 20, or 30. If Alice's, Betty's, and Carol's transactions run at about the same time, and each runs under isolation level READ COMMITTED, which sums could be produced by Alice's transaction?Explanation / Answer
The answer depends upon which set of statements gets executed first. So, there are several cases which are discussed below:
Case 1:
If Alice's transaction got executed first, then no matter whose transaction gets executed after Alice's, we get the result as 100.
Case 2:
Here, we assume Betty's transaction gets executed first. Now, we have two subcases:
a.) If Carol's transaction gets executed after Betty's then the values 20 and 30 would be deleted from the table and we get the sum as 110.
b.) If Alice's transaction gets executed after Betty's then we get the sum as 160(100 + 10 + 20 + 30).
Case 3:
Here, we assume that Carol's transaction gets executed first. As there are no 30 or 20 in the table, Carol's statements don't have any effect. Now, we have two subcases:
a.) If Alice's transaction gets executed after Carol's then we get the sum as 100(which is the original sum).
b.) If Betty's transaction gets executed after Carol's then we get the sum as 160(100 + 10 + 20 + 30).
So, the possible values of the sum are 100, 110, 160.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.