Study resource

Read at your pace, then save it for later.

Unit 8: Database Transaction Management: Exam Preparation Set

Section A — 1 Mark Questions

1. Define a transaction. [1 Mark]

Answer: A transaction is a logical unit of database processing that includes one or more database access operations.

2. What are the four ACID properties? [1 Mark]

Answer: Atomicity, Consistency, Isolation, and Durability.

3. What does the Atomicity property ensure? [1 Mark]

Answer: It ensures that either all operations of a transaction are executed, or none are.

4. Identify the final state of a successfully completed transaction. [1 Mark]

Answer: The Committed state.

5. What happens when a transaction reaches the Aborted state? [1 Mark]

Answer: The transaction is rolled back, and the database is restored to its previous consistent state.

6. Name the component responsible for implementing Atomicity and Durability. [1 Mark]

Answer: The Recovery Manager.

7. Define concurrent execution in databases. [1 Mark]

Answer: It is the simultaneous execution of multiple transactions by the database system.

8. What is a serial schedule? [1 Mark]

Answer: A schedule where each transaction executes from start to finish without any interleaving with other transactions.

9. Define serializability. [1 Mark]

Answer: A concurrent schedule is serializable if its outcome is equivalent to some serial execution of the participating transactions.

10. What is a recoverable schedule? [1 Mark]

Answer: A schedule where, for each pair of transactions Ti and Tj, if Tj reads a data item previously written by Ti, then the commit operation of Ti appears before the commit operation of Tj.

11. State the purpose of the Isolation property. [1 Mark]

Answer: It ensures that concurrent transactions do not interfere with each other's execution.

12. What is a cascading rollback? [1 Mark]

Answer: A situation where the failure of one transaction leads to the rollback of many other dependent transactions.

13. Which state does a transaction enter immediately after the last statement has been executed? [1 Mark]

Answer: The Partially Committed state.

14. Define a transaction log. [1 Mark]

Answer: A file used to record all updates made by transactions to support recovery.

15. What is conflict serializability? [1 Mark]

Answer: A schedule is conflict serializable if it is conflict equivalent to a serial schedule.

16. What does the Durability property guarantee? [1 Mark]

Answer: It guarantees that once a transaction has committed, its changes persist even in the event of a system crash.

17. Can a transaction transition from the Failed state to the Partially Committed state? [1 Mark]

Answer: No, it must go to the Aborted state.

18. What is the primary objective of concurrency control? [1 Mark]

19. Define a read-only transaction. [1 Mark]

Answer: A transaction that performs only read operations on the database.

20. What is the main goal of testing for serializability? [1 Mark]

Answer: To verify if a concurrent schedule maintains the consistency of the database as if it were executed serially.

Section B — 2/3 Mark Questions

1. Explain the difference between a Committed and an Aborted state. [2 Marks]

Answer: A Committed state indicates that the transaction has successfully finished and all its changes are permanently recorded. An Aborted state indicates that the transaction failed, and its partial changes have been undone to maintain database integrity.

2. Why is atomicity critical in banking transactions? [2 Marks]

Answer: In banking, a transfer involves debiting one account and crediting another. Atomicity ensures that if the system crashes after the debit but before the credit, the entire transaction is rolled back, preventing money from disappearing.

3. Describe the concept of a precedence graph for serializability. [3 Marks]

Answer: A precedence graph is a directed graph where nodes represent transactions and an edge Ti → Tj exists if Tj conflicts with an operation performed by Ti. A schedule is conflict serializable if and only if its precedence graph is acyclic.

4. What are the primary advantages of concurrent execution? [2 Marks]

Answer: Concurrent execution improves processor utilization and resource throughput. It also significantly reduces the average response time for users by interleaving operations.

5. Briefly explain the concept of Isolation in the context of transactions. [3 Marks]

Answer: Isolation ensures that concurrent transactions remain unaware of each other's partial results. Even though they execute simultaneously, the final state of the database appears as if each transaction executed sequentially, preventing data corruption.

6. Explain the 'Partially Committed' state in a transaction. [2 Marks]

Answer: A transaction reaches the partially committed state after its final statement has been executed, but before the changes are physically written to the non-volatile storage (committed).

7. List the conditions that make a schedule non-recoverable. [3 Marks]

Answer: A schedule is non-recoverable if a transaction Tj reads data written by Ti, and then Tj commits before Ti commits. If Ti later aborts, the database state becomes inconsistent, as Tj relied on uncommitted data.

8. What is the purpose of a log-based recovery mechanism? [2 Marks]

Answer: It maintains a sequential record of all operations. In case of a crash, the recovery manager uses this log to redo committed transactions and undo uncommitted ones to restore consistency.

9. Why is serial execution generally avoided in high-performance databases? [2 Marks]

Answer: Serial execution is inefficient because it forces transactions to wait for one another to complete, leading to poor system performance and long waiting times for users.

10. Define the 'Consistency' property in ACID. [3 Marks]

Answer: Consistency ensures that a transaction takes the database from one valid state to another, preserving all predefined integrity constraints. If a transaction violates these rules, it must be aborted to keep the database consistent.

Section C — 5 Mark Questions

1. Describe the various states of a transaction with a clear explanation of each transition. [5 Marks]

Answer:

States Explanation

  • Active: The initial state where the transaction is currently executing its instructions.
  • Partially Committed: The state after the last statement of the transaction has been executed.
  • Failed: The state where the system detects that normal execution can no longer proceed.
  • Aborted: The state after the transaction has been rolled back and the database is restored to the state it was in before the transaction started.
  • Committed: The final state after the transaction has successfully completed and all changes are permanently saved in the database.

Transitions

A transaction starts in the Active state. If it completes all operations, it moves to Partially Committed. If it successfully writes to disk, it moves to Committed. If an error occurs during the Active or Partially Committed states, it moves to Failed and then to the Aborted state.

2. Discuss the importance of Atomicity and Durability and how they are implemented. [5 Marks]

Answer:

Atomicity

Atomicity is the 'all-or-nothing' property. If any part of the transaction fails, the entire transaction is rolled back. This is implemented using logs, where the system keeps track of 'undo' information to reverse partial changes upon failure.

Durability

Durability ensures that once a transaction is committed, its effects are permanent, even if a power failure or system crash occurs. This is implemented by the Recovery Manager ensuring that all log records related to a transaction are flushed to stable (non-volatile) storage before the transaction is acknowledged as committed.

Implementation Summary

The Recovery Manager acts as the orchestrator for these properties, ensuring that the database can always be reconstructed to a consistent state by replaying or reversing operations from the log.

3. Explain the concept of Serializability and the methods used to test for it. [5 Marks]

Answer:

Concept of Serializability

Serializability is the standard for correctness in concurrent transaction processing. A schedule is considered correct if its final state is equivalent to the state resulting from some serial execution of the same set of transactions. This prevents issues like dirty reads and lost updates.

Testing for Serializability

Testing for serializability is typically done using the following steps:

  • Conflict Serializability: Construct a precedence graph. Nodes represent transactions, and a directed edge is drawn from Ti to Tj if an operation in Ti conflicts with an operation in Tj, and Ti executes first.
  • Cycle Detection: If the graph contains no cycles, the schedule is conflict serializable. If a cycle exists, the schedule is not conflict serializable.
  • Equivalence: By showing that the order of conflicting operations is preserved in a serial order, the schedule can be proven equivalent.

4. Compare and contrast Serial and Concurrent schedules, highlighting the performance trade-offs. [5 Marks]

Answer:

Serial Schedules

In a serial schedule, transactions run one after the other. Each transaction executes completely before the next begins. The primary advantage is total isolation and simplicity, as there is no interference between transactions. However, the disadvantage is extremely low performance, as CPU and I/O resources remain idle while waiting for long transactions to finish.

Concurrent Schedules

Concurrent schedules allow multiple transactions to interleave their operations. This maximizes resource utilization and improves system throughput. However, concurrent execution introduces complexity, as it requires concurrency control mechanisms (like locking) to prevent anomalies like lost updates. The system must ensure that these interleaved schedules remain serializable to maintain data integrity.

Comparison Table

FeatureSerial ScheduleConcurrent Schedule
ExecutionSequentialInterleaved
ThroughputLowHigh
ComplexitySimpleComplex
Concurrency ControlNot requiredRequired

5. What is a Recoverable Schedule, and why is it essential to avoid non-recoverable schedules? [5 Marks]

Answer:

Recoverable Schedule Definition

A schedule is recoverable if, for every pair of transactions Ti and Tj such that Tj reads a data item previously written by Ti, the commit operation of Ti appears before the commit operation of Tj. This ensures that the transaction reading the data does not permanently commit unless the transaction that provided the data also successfully commits.

Importance of Recovery

Non-recoverable schedules are dangerous because they can lead to data inconsistency. If Tj commits after reading data from Ti, and then Ti aborts, Tj has effectively committed based on data that should not exist in the database. Because Tj has already committed, the system cannot 'undo' its changes, leading to an unrecoverable state.

Avoiding Cascading Rollbacks

Database systems prefer schedules that are not only recoverable but also avoid cascading rollbacks, where one failure forces multiple dependent transactions to abort. This is achieved by ensuring that a transaction only reads data from committed transactions, maintaining strict consistency in the face of potential failures.


xxx

Did this help you understand better?

Your feedback improves the quality of this resource for everyone.