0% found this document useful (0 votes)
12 views3 pages

Transaction

The document consists of multiple choice and short answer questions related to database transactions, covering ACID properties, isolation levels, and transaction recovery concepts. Key topics include the definition of transactions, the importance of isolation, and the implications of cascading rollbacks. Additionally, it presents numerical problems demonstrating atomicity and the effects of transaction failures on account balances.

Uploaded by

RANJIT Yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views3 pages

Transaction

The document consists of multiple choice and short answer questions related to database transactions, covering ACID properties, isolation levels, and transaction recovery concepts. Key topics include the definition of transactions, the importance of isolation, and the implications of cascading rollbacks. Additionally, it presents numerical problems demonstrating atomicity and the effects of transaction failures on account balances.

Uploaded by

RANJIT Yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Multiple Choice Questions (MCQs)

Which of the following is NOT an ACID property of a 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?

A) Growing and Shrinking


B) Active and Inactive
C) Committed and Aborted
D) Read and Write
Answer: A) Growing and Shrinking
What is a recoverable schedule?

A) A schedule where all transactions are committed.


B) A schedule where a transaction can read uncommitted data.
C) A schedule where the commit of one transaction appears before the commit of
another transaction that reads its data.
D) A schedule that does not allow any rollbacks.
Answer: C) A schedule where the commit of one transaction appears before the commit
of another transaction that reads its data.
Short Answer Questions
Define a transaction in the context of a DBMS. What are its key properties?

Answer: A transaction is a sequence of operations performed as a single logical


unit of work. The key properties of a transaction are:
Atomicity: All operations must complete successfully or none at all.
Consistency: Transactions must leave the database in a consistent state.
Isolation: Transactions should not interfere with each other.
Durability: Once a transaction is committed, its changes are permanent, even in the
event of a failure.
Explain the concept of isolation in transactions. Why is it important?

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: Conflict serializability is based on the ability to transform a schedule


into a serial schedule by swapping non-conflicting operations. View
serializability, on the other hand, ensures that transactions read the same data in
both schedules, focusing on the values read and written rather than the order of
operations.
Describe the role of a log in transaction recovery. How does it help in maintaining
durability?

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:

T1: read(A), write(A), commit


T2: read(A), write(A), commit
Is this schedule conflict serializable? If yes, provide the equivalent serial
schedule. If no, explain why.
Answer: No, this schedule is not conflict serializable because T2 reads the value
of A after T1 has written to it, which creates a dependency that cannot be resolved
by swapping operations without changing the outcome.
A transaction T1 reads a value from a database, modifies it, and writes it back. If
T1 is aborted after the write operation, what steps must the DBMS take to ensure
the database remains consistent?

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:

Transaction T1: read(A), A := A - 50, write(A)


Transaction T2: read(B), B := B + 50, write(B)
Assume the initial balances are A = $200 and B = $300. What happens if T1 fails
after the first write?
Answer:
If T1 successfully completes, the final balances will be:
Account A: $150
Account B: $350
If T1 fails after the first write (but before commit), the DBMS must roll back the
transaction, restoring Account A to $200, and Account B remains at $300. Thus, the
final balances will be:
Account A: $200
Account B: $300

You might also like