Q.1 Which of the following properties ensures that a transaction in a database is all-or-nothing?
Atomicity
Consistency
Isolation
Durability
Explanation - Atomicity ensures that a transaction is either fully completed or fully rolled back, preventing partial updates.
Correct answer is: Atomicity
Q.2 In transaction management, which property ensures that the database remains in a valid state after a transaction?
Atomicity
Consistency
Isolation
Durability
Explanation - Consistency ensures that any transaction will take the database from one valid state to another, maintaining database rules.
Correct answer is: Consistency
Q.3 Which property of a transaction ensures that its effects are visible to other transactions only after it is committed?
Atomicity
Consistency
Isolation
Durability
Explanation - Isolation ensures that concurrent transactions do not interfere with each other and results of uncommitted transactions are not visible.
Correct answer is: Isolation
Q.4 Which property guarantees that once a transaction is committed, its effects cannot be lost?
Atomicity
Consistency
Isolation
Durability
Explanation - Durability ensures that the changes made by a committed transaction persist even in case of system failures.
Correct answer is: Durability
Q.5 Which of the following is NOT a type of database transaction anomaly?
Lost update
Dirty read
Deadlock
Rollback
Explanation - Rollback is a mechanism to undo transactions, whereas lost update, dirty read, and deadlock are anomalies that occur in concurrent transactions.
Correct answer is: Rollback
Q.6 What does a 'dirty read' occur in database transactions?
Reading uncommitted data from another transaction
Reading committed data multiple times
Transaction deadlock
Data inconsistency due to crash
Explanation - A dirty read happens when a transaction reads data written by another transaction that has not yet committed.
Correct answer is: Reading uncommitted data from another transaction
Q.7 Which schedule is considered safe in terms of preserving transaction consistency?
Serial schedule
Concurrent schedule
Recoverable schedule
Cascadeless schedule
Explanation - Serial schedules execute transactions one after the other, ensuring that the final state is consistent and equivalent to some serial execution.
Correct answer is: Serial schedule
Q.8 Which type of schedule allows transactions to interleave but still ensures consistency?
Serial schedule
Conflict-serializable schedule
Non-serializable schedule
Deadlock schedule
Explanation - Conflict-serializable schedules allow interleaving of operations but guarantee equivalence to some serial execution, preserving consistency.
Correct answer is: Conflict-serializable schedule
Q.9 Which mechanism is commonly used to control concurrency in databases?
Two-phase locking
Rollback segment
Checkpointing
Indexing
Explanation - Two-phase locking (2PL) ensures serializability by acquiring all required locks before releasing any, controlling concurrent access safely.
Correct answer is: Two-phase locking
Q.10 In Two-Phase Locking (2PL), what are the two phases?
Growing and shrinking
Locking and unlocking
Start and commit
Read and write
Explanation - In 2PL, the growing phase acquires all locks needed by the transaction, and the shrinking phase releases locks, ensuring serializability.
Correct answer is: Growing and shrinking
Q.11 What type of lock allows multiple transactions to read a resource but prevents writing?
Exclusive lock
Shared lock
Binary lock
Deadlock lock
Explanation - A shared lock allows multiple transactions to read a data item concurrently but prevents any transaction from writing to it.
Correct answer is: Shared lock
Q.12 Which lock type is used when a transaction intends to write a data item?
Shared lock
Exclusive lock
Binary lock
Read lock
Explanation - An exclusive lock ensures that only one transaction can read or write the data item, preventing concurrent writes or reads during modification.
Correct answer is: Exclusive lock
Q.13 What is the term for a situation where two transactions are waiting indefinitely for each other's locks?
Starvation
Deadlock
Livelock
Rollback
Explanation - Deadlock occurs when transactions wait indefinitely for resources locked by each other, preventing progress.
Correct answer is: Deadlock
Q.14 Which of the following is a method to prevent deadlocks?
Timeouts
Ignoring locks
Two-phase commit
Cascading rollback
Explanation - Deadlocks can be prevented using timeouts, where a transaction waits for a limited time for a lock before aborting or rolling back.
Correct answer is: Timeouts
Q.15 In database recovery, what is the main purpose of a checkpoint?
To periodically save database state
To enforce locks
To resolve deadlocks
To start a transaction
Explanation - Checkpoints save the current state of the database and active transactions to reduce recovery time after a crash.
Correct answer is: To periodically save database state
Q.16 Which recovery method uses logs to undo or redo transactions after a crash?
Deferred update
Immediate update
Shadow paging
Logging
Explanation - Logging records all transaction operations so that they can be undone or redone during recovery, ensuring durability and consistency.
Correct answer is: Logging
Q.17 What type of schedule avoids cascading rollbacks?
Cascadeless schedule
Recoverable schedule
Serial schedule
Conflict-serializable schedule
Explanation - Cascadeless schedules ensure that a transaction only reads data committed by other transactions, preventing cascading rollbacks.
Correct answer is: Cascadeless schedule
Q.18 Which of the following ensures that a transaction is recoverable?
A transaction reads only committed data
A transaction acquires all locks first
A transaction writes immediately
A transaction performs a checkpoint
Explanation - Recoverable schedules require that transactions only read data from committed transactions to prevent inconsistencies during rollbacks.
Correct answer is: A transaction reads only committed data
Q.19 In database concurrency control, what is the main purpose of a timestamp ordering protocol?
To order transactions chronologically
To enforce atomicity
To prevent deadlocks
To create checkpoints
Explanation - Timestamp ordering assigns timestamps to transactions and ensures that conflicting operations are executed according to these timestamps, maintaining serializability.
Correct answer is: To order transactions chronologically
Q.20 Which phenomenon occurs when a transaction reads a value and another transaction overwrites it before the first transaction commits?
Dirty read
Non-repeatable read
Phantom read
Lost update
Explanation - Lost update happens when two transactions update the same data concurrently, and one update overwrites the other without being aware of it.
Correct answer is: Lost update
Q.21 Which isolation level allows a transaction to see changes made by other uncommitted transactions?
Read uncommitted
Read committed
Repeatable read
Serializable
Explanation - Read uncommitted is the lowest isolation level, allowing dirty reads from uncommitted transactions, potentially causing inconsistencies.
Correct answer is: Read uncommitted
Q.22 Which isolation level prevents non-repeatable reads but may allow phantom reads?
Read committed
Repeatable read
Serializable
Read uncommitted
Explanation - Repeatable read ensures that repeated reads of the same data return the same value but does not prevent new rows from being inserted (phantoms).
Correct answer is: Repeatable read
Q.23 What is the strongest isolation level that ensures complete serializability?
Read uncommitted
Read committed
Repeatable read
Serializable
Explanation - Serializable isolation ensures full serializability, preventing dirty reads, non-repeatable reads, and phantom reads.
Correct answer is: Serializable
Q.24 Which of the following best describes a phantom read?
Reading new rows inserted by other transactions
Reading uncommitted data
Reading the same row differently twice
Lost update of a row
Explanation - Phantom reads occur when a transaction re-executes a query and sees new rows added by other committed transactions since the first read.
Correct answer is: Reading new rows inserted by other transactions
