Transaction
Transaction
A) Atomicity
B) Consistency
C) Durability
D) Accessibility
Answer: D) Accessibility
What is the state of a transaction after it has been rolled back?
A) Active
B) Committed
C) Aborted
D) Partially Committed
Answer: C) Aborted
Which isolation level allows dirty reads?
A) Serializable
B) Repeatable Read
C) Read Committed
D) Read Uncommitted
Answer: D) Read Uncommitted
In a two-phase locking protocol, what are the two phases called?
Answer: Isolation ensures that the operations of a transaction are not visible to
other transactions until the transaction is committed. This is important to prevent
inconsistencies in the database that can arise from concurrent transactions
accessing the same data.
What is the difference between conflict serializability and view serializability?
Answer: A log records all changes made by transactions. In the event of a failure,
the log can be used to redo or undo transactions to restore the database to a
consistent state. This ensures durability, as committed transactions can be
recovered even after a crash.
What are cascading rollbacks, and how can they affect the performance of a database
system?
Answer: Cascading rollbacks occur when a transaction fails and causes other
transactions that depend on its results to also roll back. This can lead to
significant performance degradation as multiple transactions may need to be undone,
wasting resources and time.
Numerical Problems
Consider a transaction that transfers $100 from Account A to Account B. If the
initial balances are:
Account A: $500
Account B: $300
If the transaction fails after deducting $100 from Account A but before adding it
to Account B, what will be the final balances in both accounts? Explain how this
situation violates the atomicity property.
Answer: Final balances will be:
Account A: $400 (after deduction)
Account B: $300 (no addition)
This violates atomicity because the transaction did not complete successfully; the
deduction occurred without the corresponding addition, leading to an inconsistent
state.
Given the following schedule of transactions T1 and T2:
Answer: The DBMS must roll back the changes made by T1, restoring the original
value of the data item that was modified. This is typically done using the log to
undo the write operation.
If a database system uses a two-phase locking protocol and a transaction holds a
lock on a resource for 10 seconds, what could be the potential impact on other
transactions trying to access the same resource?
Answer: Other transactions that need to access the locked resource will be blocked
until the lock is released. This can lead to increased wait times and potential
deadlocks if multiple transactions are waiting on each other.
Calculate the final balance of two accounts A and B after the following
transactions: