Question 1
EasyWhat is the purpose of concurrency control?
- A.
To back up the database
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
DBMS
What is the purpose of concurrency control?
To back up the database
To compress data
To speed up a single query
To keep the database correct when transactions run at the same time
Answer: D
It prevents problems such as lost updates and dirty reads while still allowing parallelism.
What is a shared (S) lock used for?
Writing: only one transaction can hold it
Creating an index
Reading: several transactions can hold it on the same item
Deleting a table
Answer: C
Shared locks are compatible with each other but not with exclusive locks.
What is an exclusive (X) lock used for?
Sharing data between users
Backing up data
Reading only
Writing: no other transaction may read or write the item
Answer: D
An X lock is incompatible with every other lock on the same item.
What is a lost update?
An update to a deleted row
An update that is rolled back
An update that takes too long
Two transactions read and update the same item, and one update overwrites the other
Answer: D
For example, two clerks both read a balance of 100 and each adds 10; the result is 110 instead of 120.
What is a schedule in concurrency control?
An order in which the operations of concurrent transactions are executed
A timetable of backups
A table's index
A list of users
Answer: A
A serial schedule runs transactions one after another; a concurrent schedule interleaves them.
Which schedules are always correct?
Schedules without locks
Schedules with dirty reads
Any interleaved schedule
Serial schedules
Answer: D
Running transactions one at a time keeps the database consistent; concurrency control accepts only interleavings equivalent to some serial order.
What happens in a deadlock between two transactions?
One transaction commits twice
Each waits for a lock the other holds, so neither can proceed
Both read the same data
Both finish together
Answer: B
The DBMS detects the cycle and aborts one transaction (the victim) to break it.
In a DBMS, what is a lock?
A broken transaction
A key used to encrypt data
A password for the database
A mechanism that controls concurrent access to a data item
Answer: D
Transactions must hold the right lock before reading or writing an item.
Can two transactions hold shared locks on the same item at the same time?
No, never
Yes, because both are only reading
Only on weekends
Only if they belong to the same user
Answer: B
Shared (read) locks are compatible with each other.
Transaction T1 holds a shared lock on an item. Can T2 obtain an exclusive lock on it at once?
No, T2 must wait until the shared lock is released
Yes, exclusive locks always win
Only if the item is empty
Yes, if T2 is newer
Answer: A
An exclusive lock is incompatible with any other lock on the same item.