Transaction · Databases
38 questions · asked in 20 of 27 years (2000–2026)
MCQ 32 · MSQ 5 · NAT 11-mark 19 · 2-mark 19
2000Questions per year2026
Questions 31–35 of 38
Consider the following schedules involving two transactions. Which one of the
following statements is TRUE?
Answer: (C)
Two operations conflict when they are on the same item, in different transactions, and at least one is a write. Add an edge when the operation of comes first.
- Take : comes before , so . comes before , so . The graph has a cycle, so the schedule is not conflict serializable.
- Take : comes before , so . comes before , so . There is only one direction of edges, so the schedule is conflict serializable.
S1 is not conflict serializable and S2 is conflict serializable.
Answer: (C)
- Take : comes before , so . comes before , so . The graph has a cycle, so the schedule is not conflict serializable.
- Take : comes before , so . comes before , so . There is only one direction of edges, so the schedule is conflict serializable.
S1 is not conflict serializable and S2 is conflict serializable.
Answer: (C)
Consider the following log sequence of two transactions on a bank account, with initial balance 12000,that transfer 2000 to a mortgage payment and, then apply a 5% interest.
1. T1 start
2. T1 B old = 12000 new = 10000
3. T1 M old = 0 new = 2000
4. T1 commit
5. T2 start
6. T2 B old = 10000 new = 10500
7. T2 commit
Suppose the database system crashed just before log record 7 is written. When the system is restarted, which one statement is true of the recovery procedure?
1. T1 start
2. T1 B old = 12000 new = 10000
3. T1 M old = 0 new = 2000
4. T1 commit
5. T2 start
6. T2 B old = 10000 new = 10500
7. T2 commit
Suppose the database system crashed just before log record 7 is written. When the system is restarted, which one statement is true of the recovery procedure?
Answer: (B)
The system crashes before T2's commit record (record 7) is written. So T2 has not committed, and its change must be undone: record 6 is undone and B is set back to 10000.
T1 has committed (record 4), so its changes, records 2 and 3, must be redone. A commit record only means the log is safe on disk. The updated data pages of T1 may still have been in memory when the system crashed (no checkpoint is shown), so recovery has to apply them again.
Why the other options are wrong:
- (A) is wrong because record 6 belongs to T2, which has not committed, so it is undone, not redone.
- (C) is wrong because a commit does not guarantee that the changes reached the data pages on disk, so redo is still needed.
- (D) is wrong because idempotent only means that repeating the same operation gives the same result. It does not mean an undo and a redo on the same item can be swapped. In general the last one applied decides the final value, so recovery applies them in a fixed order. (In this log both give B = 10000, but the rule does not rely on that.)
Answer: (B)
T1 has committed (record 4), so its changes, records 2 and 3, must be redone. A commit record only means the log is safe on disk. The updated data pages of T1 may still have been in memory when the system crashed (no checkpoint is shown), so recovery has to apply them again.
Why the other options are wrong:
- (A) is wrong because record 6 belongs to T2, which has not committed, so it is undone, not redone.
- (C) is wrong because a commit does not guarantee that the changes reached the data pages on disk, so redo is still needed.
- (D) is wrong because idempotent only means that repeating the same operation gives the same result. It does not mean an undo and a redo on the same item can be swapped. In general the last one applied decides the final value, so recovery applies them in a fixed order. (In this log both give B = 10000, but the rule does not rely on that.)
Answer: (B)
A company maintains records of sales made by its salespersons and pays them commission based on each individual's total sales made in a year. This data is maintained in a table with following schema:
salesinfo = (salespersonid, totalsales, commission)
In a certain year, due to better business results, the company decides to further reward its salespersons by enhancing the commission paid to them as per the following formula:
If commission , enhance it by 2%
If 50000 < commission , enhance it by 4%
If commission > 100000, enhance it by 6%
The IT staff has written three different SQL scripts to calculate enhancement for each slab, each of these scripts is to run as a separate transaction as follows:
T1
T2
T3
Which of the following options of running these transactions will update the commission of all salespersons correctly
salesinfo = (salespersonid, totalsales, commission)
In a certain year, due to better business results, the company decides to further reward its salespersons by enhancing the commission paid to them as per the following formula:
If commission , enhance it by 2%
If 50000 < commission , enhance it by 4%
If commission > 100000, enhance it by 6%
The IT staff has written three different SQL scripts to calculate enhancement for each slab, each of these scripts is to run as a separate transaction as follows:
T1
Update salesinfo
Set commission = commission * 1.02
Where commission < = 50000; T2
Update salesinfo
Set commission = commission * 1.04
Where commission > 50000 and commission is < = 100000; T3
Update salesinfo
Set commission = commission * 1.06
Where commission > 100000; Which of the following options of running these transactions will update the commission of all salespersons correctly
Answer: (D)
The right order is , then , then : the highest slab goes first. A raise moves a commission up, and it may cross into a higher slab. If that higher slab's transaction has already run, nobody raises the commission a second time. So each person gets exactly one raise.
In the other options, some people get the raise two times.
(A) then then : say the starting commission is . This is in the slab , so . Now it is in the second slab, so gives . The person gets two raises, but should get only one.
(B) and (C): runs at the same time as the others, so it may run before has done its update. Then the case above happens again. In (B) there is a second problem: followed by can raise to , which then raises again.
Answer: (D)
In the other options, some people get the raise two times.
(A) then then : say the starting commission is . This is in the slab , so . Now it is in the second slab, so gives . The person gets two raises, but should get only one.
(B) and (C): runs at the same time as the others, so it may run before has done its update. Then the case above happens again. In (B) there is a second problem: followed by can raise to , which then raises again.
Answer: (D)
Amongst the ACID properties of a transaction, the 'Durability' property requires that the changes made to the database by a successful transaction persist
Answer: (D)
Durability says that once a transaction has committed, its changes must stay in the database whatever kind of failure happens later: an operating system crash, a disk crash or a power failure.
Say we book a ticket months ahead on IRCTC, and the transaction succeeds. Later, when we come to board the train, they say that a system, disk or power crash has lost our seat information, so we are not allowed on the seat. This is a serious problem. So the result must persist after every kind of failure, and options (A), (B) and (C), which allow an exception, are wrong.
Answer: (D)
Say we book a ticket months ahead on IRCTC, and the transaction succeeds. Later, when we come to board the train, they say that a system, disk or power crash has lost our seat information, so we are not allowed on the seat. This is a serious problem. So the result must persist after every kind of failure, and options (A), (B) and (C), which allow an exception, are wrong.
Answer: (D)
Consider the following schedule S of transactions T1 and T2:
Which of the following is TRUE about the schedule S ?
Which of the following is TRUE about the schedule S ?
Answer: (D)
A schedule is serializable if, for every initial database state, its effect is the same as that of some serial schedule. This is wider than conflict or view serializability.
A schedule can be neither conflict nor view serializable and still be serializable, because the actual computations decide the final values. For example, here each transaction only adds a constant, and the additions can be done in either order, so the schedule gives the same result as both and :
Since the computations are given in this question, compare the final values directly. Let and at the start. The given schedule ends with and :
Serial schedule ends with and :
Serial schedule ends with and :
The value of in the given schedule matches neither serial schedule. So the schedule is not serializable as and not as .
For contrast, change to . This schedule ends with and :
gives , the same result:
gives , which is different:
So is serializable only as , even though it is neither conflict nor view serializable. When the computations are given, check serializability from the final values like this; for the question as given, no serial order matches.
Answer: (D)
A schedule can be neither conflict nor view serializable and still be serializable, because the actual computations decide the final values. For example, here each transaction only adds a constant, and the additions can be done in either order, so the schedule gives the same result as both and :
Since the computations are given in this question, compare the final values directly. Let and at the start. The given schedule ends with and :
Serial schedule ends with and :
Serial schedule ends with and :
The value of in the given schedule matches neither serial schedule. So the schedule is not serializable as and not as .
For contrast, change to . This schedule ends with and :
gives , the same result:
gives , which is different:
So is serializable only as , even though it is neither conflict nor view serializable. When the computations are given, check serializability from the final values like this; for the question as given, no serial order matches.
Answer: (D)
Keep practising