What is the main purpose of timestamp-based protocols in databases?
Timestamp-based protocols help manage the order of transactions to avoid conflicts and ensure consistency by using timestamps to decide which transaction should proceed.
Click to reveal answer
beginner
How does a timestamp determine the order of transactions?
Each transaction is given a unique timestamp when it starts. Transactions with smaller timestamps are considered older and get priority over newer ones.
Click to reveal answer
intermediate
What happens if a transaction tries to access data that conflicts with a newer transaction in timestamp-based protocols?
The older transaction may be rolled back or delayed to maintain the correct order, preventing conflicts and ensuring data consistency.
Click to reveal answer
intermediate
Explain the difference between read and write timestamps in timestamp-based protocols.
Read timestamp records the last time data was read, and write timestamp records the last time data was written. These help decide if a transaction can safely read or write data without conflicts.
Click to reveal answer
advanced
Why are timestamp-based protocols considered non-locking concurrency control methods?
Because they do not use locks to control access but rely on timestamps to order transactions, reducing waiting times and deadlocks.
Click to reveal answer
What does a smaller timestamp indicate in timestamp-based protocols?
AAn older transaction
BA newer transaction
CA transaction with higher priority to write
DA transaction that must be rolled back
✗ Incorrect
Smaller timestamps mean the transaction started earlier, so it is older and usually given priority.
In timestamp-based protocols, what happens if a transaction tries to write data that has been read by a newer transaction?
AThe newer transaction is rolled back
BThe write is allowed immediately
CThe transaction is rolled back
DBoth transactions proceed simultaneously
✗ Incorrect
To maintain order, the older transaction must roll back if it tries to write data already read by a newer transaction.
Which of the following is NOT a feature of timestamp-based protocols?
AAssigning unique timestamps to transactions
BUse of locks to control access
COrdering transactions by timestamp
DAvoiding deadlocks
✗ Incorrect
Timestamp-based protocols do not use locks; they rely on timestamps to order transactions.
What do read and write timestamps help determine?
AIf a transaction can safely read or write data
BThe size of the transaction
CWhen to commit a transaction
DThe priority of the database server
✗ Incorrect
Read and write timestamps help decide if a transaction can access data without causing conflicts.
Why might a transaction be rolled back in timestamp-based protocols?
ABecause it has the newest timestamp
BBecause it completed successfully
CBecause it requested a lock
DBecause it conflicts with the order of timestamps
✗ Incorrect
Transactions that violate the timestamp order are rolled back to maintain consistency.
Describe how timestamp-based protocols use timestamps to manage transaction order and avoid conflicts.
Think about how the system decides which transaction goes first.
You got /4 concepts.
Explain the role of read and write timestamps in timestamp-based concurrency control.
Consider how the system knows if data access is safe.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of timestamps in timestamp-based protocols in DBMS?
easy
A. To give each transaction a unique order number
B. To encrypt the data during transactions
C. To store the transaction results permanently
D. To backup the database automatically
Solution
Step 1: Understand the role of timestamps
Timestamps assign a unique number to each transaction to order them.
Step 2: Identify the main purpose in protocols
This ordering helps the system decide which transaction can read or write data safely.
Final Answer:
To give each transaction a unique order number -> Option A
Quick Check:
Timestamps = Unique order number [OK]
Hint: Timestamps order transactions uniquely [OK]
Common Mistakes:
Confusing timestamps with encryption keys
Thinking timestamps store data permanently
Assuming timestamps handle backups
2. Which of the following is the correct way to assign a timestamp to a transaction in a timestamp-based protocol?
easy
A. Assign the current system time as the timestamp
B. Assign a random number as the timestamp
C. Assign the transaction ID as the timestamp
D. Assign the timestamp after the transaction commits
Solution
Step 1: Understand timestamp assignment
Timestamps are usually assigned based on the current system time to reflect order.
Step 2: Evaluate options
Random numbers or transaction IDs do not guarantee correct ordering; timestamps must be assigned before commit.
Final Answer:
Assign the current system time as the timestamp -> Option A
Quick Check:
Timestamp = Current system time [OK]
Hint: Use system time for timestamps [OK]
Common Mistakes:
Using random numbers instead of time
Assigning timestamp after commit
Confusing transaction ID with timestamp
3. Consider two transactions T1 and T2 with timestamps TS(T1) = 5 and TS(T2) = 10. If T1 tries to write a data item that T2 has already written, what will happen according to timestamp-based protocols?
medium
A. T1 will overwrite T2's write because it started earlier
B. T2 will be rolled back because it started later
C. T1 will be rolled back to prevent overwriting newer data
D. Both transactions will commit successfully
Solution
Step 1: Compare timestamps of T1 and T2
T1 has timestamp 5 (older), T2 has timestamp 10 (newer).
Step 2: Apply timestamp protocol rule
Older transactions cannot overwrite changes made by newer transactions, so T1 must be rolled back.
Final Answer:
T1 will be rolled back to prevent overwriting newer data -> Option C
Thinking older transactions can overwrite newer writes
Assuming both transactions commit
Confusing which transaction rolls back
4. Identify the error in this scenario: Transaction T3 with timestamp 15 reads a data item last written by T4 with timestamp 20. According to timestamp-based protocols, what is wrong if T3 reads the old value?
medium
A. No error, reading old value is allowed
B. T4 should roll back because T3 read first
C. T3 can read any value without restrictions
D. T3 should not read because it is older than T4's write
Solution
Step 1: Compare timestamps of T3 and T4
T3 has timestamp 15 (older), T4 has timestamp 20 (newer).
Step 2: Apply read rule in timestamp protocol
Older transactions cannot read data written by newer transactions because it causes inconsistency.
Final Answer:
T3 should not read because it is older than T4's write -> Option D
Quick Check:
Older transaction reading newer write = Not allowed [OK]
5. In a timestamp-based protocol, if a transaction T5 with timestamp 25 tries to write a data item that was last read by transaction T6 with timestamp 30, what should happen to maintain consistency?
hard
A. T6 should be rolled back because it read before T5's write
B. T5 should be rolled back because it is older than T6
C. Both transactions can proceed without rollback
D. T5 can write only if T6 commits first
Solution
Step 1: Analyze timestamps of T5 and T6
T5 has timestamp 25 (older), T6 has timestamp 30 (newer).
Step 2: Apply write rule in timestamp protocol
Older transaction T5 cannot write if a newer transaction T6 has already read the data, to avoid inconsistency.
Step 3: Decide action to maintain consistency
T5 must be rolled back to prevent overwriting data read by newer transaction T6.
Final Answer:
T5 should be rolled back because it is older than T6 -> Option B
Quick Check:
Older write after newer read = Rollback older [OK]
Hint: Older writes after newer reads cause rollback [OK]
Common Mistakes:
Allowing older writes after newer reads
Rolling back newer transaction incorrectly
Assuming both can proceed safely
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.