programming beginner 10 sample questions

Transaction Management MCQ Practice Test

Ensuring data integrity with ACID properties (Atomicity, Consistency, Isolation, Durability).

Q1. A database transaction is rolled back due to a deadlock. Which of the following is a characteristic of the transaction that was rolled back?

Explanation: A deadlock occurs when two or more transactions are blocked indefinitely, waiting for each other to release resources. In this case, the transaction that was rolled back likely held locks on multiple resources for an extended period, contributing to the deadlock.

Q2. In a database transaction, what is the purpose of the "savepoint" feature in MySQL?

Explanation: A savepoint is a temporary mark within a transaction that allows the transaction to be rolled back to that point without affecting the entire transaction. This feature is useful for isolating a portion of a transaction and rolling it back independently of the rest of the transaction.

Q3. In a database transaction, which of the following is an example of a cascading update that occurs when a parent table's primary key is updated?

Explanation: A cascading update is a type of constraint that automatically updates related records in a database when a primary key is updated. This is often used in referential integrity to maintain data consistency.

Q4. In a database system that supports nested transactions, what is the purpose of the "Savepoint" mechanism?

Explanation: The Savepoint mechanism allows a transaction manager to create a temporary point within a transaction to which changes can be rolled back in case of a failure, enabling the transaction to be recovered and retried.

Q5. In a database transaction using pessimistic locking, which of the following statements best describes the effect of a roll back operation on a locked resource?

Explanation: In pessimistic locking, when a transaction rolls back, all locks held by the transaction are released, making the resources available to other transactions. This is in contrast to optimistic locking, where locks are held until the transaction commits or rolls back.

Q6. In a database transaction, which of the following isolation levels ensures that a transaction will see a consistent view of the database, but may not see its own changes until it is committed?

Explanation: In Repeatable Read isolation level, a transaction will see a consistent view of the database, but may not see its own changes until it is committed. This is because the transaction will see the data as it was at the start of the transaction, and will not see any changes made by other transactions until it is committed.

Q7. Which SQL transaction isolation level is the weakest, allowing dirty reads (reading uncommitted changes from other transactions)?

Explanation: READ UNCOMMITTED permits reading data other transactions have not yet committed (dirty reads); each stronger level eliminates more anomalies, up to SERIALIZABLE.

Q8. A database transaction is considered "consistent" if it follows the ACID principle. Which of the following statements about consistency in database transactions is correct?

Explanation: A consistent transaction doesn't violate any constraints, such as primary key or foreign key constraints, during its execution. This ensures that the database remains in a consistent state even in the presence of concurrent transactions.

Q9. In database systems, what does a SAVEPOINT do?

Explanation: A savepoint is a marker inside an uncommitted transaction; ROLLBACK TO SAVEPOINT undoes only the work after it. Nothing is partially committed — the whole transaction remains atomic until COMMIT.

Q10. In a database transaction, which of the following is an example of an error that typically leads to a transaction being rolled back?

Explanation: A disk full error prevents the database from writing data to disk, which is a critical operation for transaction completion. This usually results in the transaction being rolled back to maintain data consistency. While the database might attempt to handle the error, it's not a seamless recovery. Deadlocks, network issues, and timeouts also commonly cause rollbacks.

That was just a sample. Sign up to unlock the full question bank with timed tests and certificates.

Sign Up Free
Transaction Management MCQ Practice Test | Mind Hustle