This section contains carefully selected MCQs and Previous Year Questions with explanations to help students understand concepts and prepare effectively for examinations, interviews, and competitive tests.
Q: 1Two phase locking protocol has which of the following problem(s)?
Option D
Two-Phase Locking (2PL) protocol, which is used for concurrency control in database systems, has the problems of deadlock and cascading rollback.
Q: 2Which of the following concurrency control protocols ensure both conflict serializability and freedom from deadlock?
(I) 2PL (Two Phase Lock)
(II) Time-Stamp ordering
(III) Multiple granularity protocol
Option B
Concurrency Control in a database ensures that when multiple transactions run at the same time, they do not interfere with each other. Its main goal is to maintain correctness, consistency, and isolation so that the final result remains the same as if transactions were executed one by one.
When we check concurrency control protocols, we look for two important properties:
Two Phase Locking (2PL) ensures conflict serializability by enforcing that transactions lock data in two phases (growing and shrinking), but it does not guarantee freedom from deadlock. The deadlocks can still occur in 2PL.
Timestamp Ordering Protocol guarantees both conflict serializability and freedom from deadlock because it assigns timestamps to transactions and schedules operations based on these timestamps, avoiding cyclic waits and deadlocks.
Multiple Granularity Protocol primarily helps reduce lock overhead and increase concurrency by using locks at different levels of granularity, but it does not guarantee deadlock freedom by itself. The deadlock can still occur.
Q: 3Which of the locking provides the highest degree of concurrency in a relational database management system?
Option B
Concurrency in a database means allowing multiple transactions to execute simultaneously without interfering with each other.
Locking mechanisms control how data is accessed during transactions. The smaller the unit of locking, the higher the concurrency.
| LOCK TYPE | DESCRIPTION | CONCURRENCY LEVEL |
|---|---|---|
| Database Locking | Locks the entire database for a transaction. No other transaction can access the database until the lock is released. Used rarely due to heavy restriction. | Very Low |
| Table Locking | Locks the complete table. Other transactions cannot modify the table until the lock is released. | Low |
| Page Locking | Locks the page. A page is fixed-size block containing multiple rows. Other transactions can access rows in different pages. | Medium |
| Row Locking | Locks only a single row. Other transactions can access and modify other rows in the same table. | High |
Q: 4Which of the following statements correctly differentiates strict two-phase locking from rigorous two-phase locking?
Option A
Two-Phase Locking (2PL) is a concurrency control protocol used in databases to ensure serializability of transactions.
Strict 2PL and Rigorous 2PL are two variants of the two-phase locking protocol. In strict 2PL, only exclusive locks are held until the transaction commits, while shared locks can be released earlier.
In rigorous 2PL, all locks, both shared and exclusive are held until the end of the transaction. This makes rigorous 2PL stricter and ensures that no other transaction can access any locked data until the current transaction completes, providing serializability and strictness.
Q: 5Which of the following scenarios may lead to an irrecoverable error in the data system?
Option D
In database systems, Recoverability ensures that no transaction commits based on uncommitted (temporary) data. If this rule is violated, it can lead to irrecoverable errors.
If a transaction reads data written by another uncommitted transaction, it is called a Dirty Read. If the first transaction later rolls back, the second transaction has already used incorrect data and result is system cannot recover properly.
Q: 6In a relational database, which level of locking provides the highest degree of concurrency?
Option B
In databases, Locking is used to control access to data and maintain consistency during transactions. The level of locking determines how much data is locked at a time and directly affects concurrency.
Row-Level Locking provides the highest degree of concurrency because only a single row is locked, allowing other transactions to access and modify other rows simultaneously.
Table-Level Locking locks the entire table, reducing concurrency since no other transaction can access it.
Column-Level Locking is not commonly used in practice and does not typically offer better concurrency than row-level locking.
Q: 7The concept of locking can be used to solve which of the following problems?
Option D
Locking is a concurrency control technique used in DBMS to ensure that multiple transactions do not interfere with each other.
Lost update occurs when two transactions update the same data and one update overwrites the other. Locking prevents this by allowing only one transaction to modify data at a time.
Uncommitted dependency or dirty read happens when a transaction reads data written by another uncommitted transaction. Locking avoids this by restricting access until commit.
Inconsistent data results from simultaneous uncontrolled access to data, which locking helps prevent.
You have reached the end of this topic. Continue learning with the next topic below.
Thank you so much for taking the time to read my Computer Science MCQs section carefully. Your support and interest mean a lot, and I truly appreciate you being part of this journey. Stay connected for more insights and updates! If you'd like to explore more tutorials and insights, check out my YouTube channel.
Don’t forget to subscribe and stay connected for future updates.