The questions can come in any order, so make sure you are selecting right option for all questions.
1. What is the primary purpose of the Two-Phase Locking (2PL) protocol in database management systems?
(a) Ensure consistency in concurrent transactions
2. Select the types of locks.
(b) Shared lock (d) Exclusive lock
3. Which mechanism is commonly used to break deadlocks in a database system?
(a) Rollback and Restart
4. You cannot upgrade shared lock.
(b) FALSE
5. In the context of locking, what is an Exclusive Lock used for?
(b) Prevents multiple transactions from writing simultaneously
6. Locking protocol consists of …..
(a) A set of locking types. (b) A set of rules indicating what locks can be granted concurrently. (c) A set of rules that transactions must follow when acquiring and releasing locks.
7. Key value locking provides increased concurrency
(a) TRUE
8. What does the term "lock granularity" refer to in the context of database locking?
(b) The level of detail at which locks are applied (e.g., at the row or table level)
9. Which phase of the Two-Phase Locking protocol ensures that no new locks are acquired by a transaction?
(b) Shrinking Phase
T34: read(A);
read(B);
if A = O then B := B + 1;
write(B).
T35: read(B);
read(A);
if B = O then A := A + 1;
write(A).
Add lock and unlock instructions to transactions T31 and T32, so that they observe the two-phase locking protocol. (HINT: USE APPROPRIATE OPTIONS SUCH AS lock-S(A), lock-X(B), unlock(A), unlock(B), lock-S(B), lock-X(A))
Block 1
lock-S(A)
Block 2
lock-X(B)
Block 3
unlock(A)
Block 4
unlock(B)
Block 5
lock-S(B)
Block 6
lock-X(A)
Block 7
unlock(B)
Block 8
unlock(A)
11. Which of the following best describes a Shared Lock?
(c) Allows multiple transactions to read simultaneously
12. Who generates locks?
(c) Lock manager
13. In the context of locking, what is a Deadlock?
(a) A situation where transactions are waiting for each other to release locks indefinitely