A concurrency management method called timestamp ordering employs timestamps to arrange transactions and guarantee serializability. Each transaction is given a distinct timestamp when it is initiated, which is how it operates. When the transaction is finished being executed, the timestamp is used to rank it in relation to other transactions.
This is an illustration of how timestamp ordering functions:
Simply,
In DBMS Lecturer’s Language 😉 FYI, I was a Lecturer earlier. Haha!
- • Timestamp Assignment (TS): Each transaction Ti is assigned a unique, monotonically increasing timestamp upon entry (TS(T1) = 1, TS(T2) = 2, TS(T3) = 3).
- • Read-Timestamp R-TS(X) & Write-Timestamp W-TS(X): Every data item tracks the timestamp of the youngest transaction that successfully read or wrote to it.
-
•
Concurrency Validation:
- ⁃ When T2 reads data written by T1, the system validates TS(T2) ≥ W-TS(D1) (2 ≥ 1). Since T2 is younger, the read is valid and preserves serializability.
- ⁃ Similarly, when T3 reads D2 written by T1, TS(T3) ≥ W-TS(D2) (3 ≥ 1), which is allowed without conflict.
The transactions in this example are carried out in the following succession: 1, 2, 3. This is due to the fact that the timestamps attached to each transaction show the chronological sequence in which they were initiated.
Below is a typical timestamp ordering algorithm:
Simple One (Works for Business Related Courses)
Technical One (Works for IT Related Courses)
For each data item X: Initialize R-TS(X) = 0, W-TS(X) = 0.
1. TRANSACTION BEGIN (Ti):
Assign TS(Ti) = current_global_timestamp;
current_global_timestamp++;
2. Ti REQUESTS READ(X):
If (TS(Ti) < W-TS(X))
Then Abort and Rollback Ti;
Else Allow Read AND Set R-TS(X) = Max(R-TS(X), TS(Ti));
3. Ti REQUESTS WRITE(X):
If (TS(Ti) < R-TS(X) OR TS(Ti) < W-TS(X))
Then Abort and Rollback Ti;
Else Allow Write AND Set W-TS(X) = TS(Ti);
4. Ti COMMIT/ABORT:
History preserves serializability based on original entry order.
Thanks for bearing me up-to this point!
Happy Learning!
– Sagar Sir


