Schedules (Histories) of Transactions
Schedules (Histories) of Transactions – Detailed Explanation
Schedules are important because they help the DBMS handle:
-
Concurrency control
-
Recovery after failures
-
Transaction correctness
1. What is a Schedule?
A schedule (S) is the sequence or ordering of operations from multiple transactions.
If there are n transactions:
A schedule S arranges their operations in a specific order.
Key Rule
Even though operations from different transactions may be interleaved, the order of operations within each individual transaction must remain unchanged.
Example
Transaction T1
Transaction T2
Possible schedule:
Here:
-
Operations of T1 and T2 are interleaved
-
But the internal order of T1 and T2 operations remains unchanged
2. Total Ordering of Operations
In schedules, operations follow total ordering.
This means:
For any two operations in the schedule, one operation must occur before the other.
Example:
Even if operations run concurrently in reality, the schedule represents them as a specific sequence.
Partial Order (Theoretical Concept)
Sometimes operations may not require strict ordering if they do not conflict.
This leads to a partial order.
However, for simplicity, database theory usually assumes total ordering of operations.
3. Important Operations in a Schedule
For recovery and concurrency control, the important operations are:
| Operation | Meaning |
|---|---|
| read_item(X) | Read data item X |
| write_item(X) | Write data item X |
| commit | Transaction successfully completed |
| abort | Transaction failed and rolled back |
4. Shorthand Notation for Schedules
Schedules are often written using short symbols.
| Symbol | Operation |
|---|---|
| b | begin transaction |
| r | read |
| w | write |
| e | end transaction |
| c | commit |
| a | abort |
A subscript indicates the transaction number.
Example
Meaning:
Another example:
Meaning:
5. Example Schedules
Schedule Sa
Explanation:
| Operation | Meaning |
|---|---|
| r1(X) | T1 reads X |
| r2(X) | T2 reads X |
| w1(X) | T1 writes X |
| r1(Y) | T1 reads Y |
| w2(X) | T2 writes X |
| w1(Y) | T1 writes Y |
Operations of T1 and T2 are interleaved.
Schedule Sb
Explanation:
| Operation | Meaning |
|---|---|
| r1(X) | T1 reads X |
| w1(X) | T1 writes X |
| r2(X) | T2 reads X |
| w2(X) | T2 writes X |
| r1(Y) | T1 reads Y |
| a1 | T1 aborts |
Here T1 fails (aborts).
6. Conflicting Operations in a Schedule
Two operations are said to conflict if three conditions are satisfied.
Conditions for Conflict
-
They belong to different transactions
-
They access the same data item
-
At least one operation is a write
Example Conflicts
In schedule Sa:
These conflict because:
-
Different transactions
-
Same data item X
-
One operation is write
Other Conflicts
7. Non-Conflicting Operations
Some operations do not conflict.
Example 1
Both are read operations, so changing their order does not change the result.
Example 2
They access different data items.
Example 3
They belong to the same transaction, so they do not conflict.
8. Why Conflicts Matter
Conflicting operations matter because changing their order may change the result of the schedule.
Example: Read-Write Conflict
Original order:
T1 reads old value of X.
If order changes:
Now T1 reads the new value written by T2.
Result is different, so this is a read-write conflict.
Example: Write-Write Conflict
Original:
Final value written by T2.
If order changes:
Final value written by T1.
Thus final result changes.
9. Complete Schedule
A schedule S is called a complete schedule if it satisfies three conditions.
Condition 1
All operations of all transactions must appear in the schedule, including:
Condition 2
The order of operations within each transaction must remain unchanged.
Example:
If T1 originally executes:
The schedule cannot change it to:
Condition 3
For conflicting operations, the schedule must specify which operation occurs first.
This ensures that the database knows how conflicts are resolved.
10. Partial vs Total Order
The schedule may leave nonconflicting operations unordered, creating a partial order.
But:
-
Conflicting operations must always have a defined order
-
Operations of the same transaction must also have a defined order
11. Active Transactions in a Schedule
In a complete schedule:
-
Every transaction must either commit or abort
-
No transaction remains active at the end
12. Committed Projection of a Schedule
In real systems, schedules often contain transactions that have not finished yet.
Therefore, we use Committed Projection C(S).
Definition
Committed Projection C(S) includes only the operations of committed transactions.
Transactions that abort or remain active are ignored.
Example
Schedule:
Committed projection C(S) will include only T2 operations because:
-
T2 committed
-
T1 aborted
Key Summary
A schedule is the ordered sequence of operations from multiple concurrent transactions.
Important concepts:
| Concept | Meaning |
|---|---|
| Schedule | Order of operations from concurrent transactions |
| Interleaving | Mixing operations of different transactions |
| Conflicting operations | Operations accessing same item with at least one write |
| Complete schedule | Includes all operations with commit/abort |
| Committed projection | Schedule containing only committed transactions |
✅ Main Idea
Schedules describe how concurrent transactions execute in a database system, ensuring correct concurrency control and recovery after failures.
Comments
Post a Comment