0
0
DBMS Theoryknowledge~20 mins

Lock-based protocols in DBMS Theory - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
πŸŽ–οΈ
Lock-based Protocols Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Two-Phase Locking (2PL)

Which statement best describes the Two-Phase Locking (2PL) protocol in database systems?

AIt requires transactions to acquire all locks before releasing any, ensuring serializability.
BIt allows transactions to release locks before acquiring new ones, improving concurrency.
CIt permits transactions to acquire and release locks in any order without restrictions.
DIt uses timestamps instead of locks to control transaction execution order.
Attempts:
2 left
πŸ’‘ Hint

Think about how 2PL controls when locks can be acquired and released to avoid conflicts.

πŸ“‹ Factual
intermediate
2:00remaining
Lock Compatibility Matrix

In lock-based protocols, which of the following lock pairs are compatible, allowing concurrent access?

AExclusive lock and Exclusive lock
BExclusive lock and Shared lock
CShared lock and Shared lock
DShared lock and Exclusive lock
Attempts:
2 left
πŸ’‘ Hint

Consider which locks allow reading and which prevent others from accessing.

πŸ” Analysis
advanced
2:00remaining
Deadlock Detection Scenario

Consider two transactions T1 and T2. T1 holds a lock on resource A and requests a lock on resource B. T2 holds a lock on resource B and requests a lock on resource A. What is the outcome?

AT1 proceeds first, then T2, no deadlock occurs.
BDeadlock occurs because both transactions wait indefinitely for each other’s locks.
CBoth transactions abort immediately to avoid deadlock.
DLocks are granted simultaneously, so no waiting occurs.
Attempts:
2 left
πŸ’‘ Hint

Think about what happens when two transactions wait for each other’s locked resources.

❓ Comparison
advanced
2:00remaining
Strict 2PL vs Rigorous 2PL

Which of the following correctly distinguishes Strict Two-Phase Locking (Strict 2PL) from Rigorous Two-Phase Locking (Rigorous 2PL)?

AStrict 2PL allows shared locks to be released early; Rigorous 2PL releases exclusive locks early.
BStrict 2PL uses timestamps; Rigorous 2PL uses lock queues.
CStrict 2PL releases locks as soon as possible; Rigorous 2PL holds locks until the transaction aborts.
DStrict 2PL releases all exclusive locks only at commit time; Rigorous 2PL releases all locks (shared and exclusive) only at commit time.
Attempts:
2 left
πŸ’‘ Hint

Focus on when locks are released in each protocol.

❓ Reasoning
expert
2:00remaining
Impact of Lock Granularity on Concurrency

How does using finer lock granularity (e.g., row-level locks) compared to coarser granularity (e.g., table-level locks) affect concurrency and overhead in a database system?

AFiner granularity increases concurrency but also increases locking overhead and complexity.
BFiner granularity decreases concurrency and reduces overhead.
CCoarser granularity increases concurrency and reduces overhead.
DLock granularity has no effect on concurrency or overhead.
Attempts:
2 left
πŸ’‘ Hint

Think about how locking smaller parts affects how many transactions can run simultaneously and the cost of managing locks.