Do you think IIT Guwahati certified course can help you in your career?
No
Introduction
In the article, we will briefly learn about Schedules and, and then we will learn about the conditions of the schedules to be View-Equivalent. To get a better picture of the topic, we will also be looking into some examples.
So Ninjas let us get into the topic with some basic terms.
Schedules
The term "schedule" refers to a sequence of operations from one transaction to the next. It's utilized to keep the sequence of the processes in each transaction separate.
There are three types of Schedules:
Serial Schedule
Non-serial schedule
Serializable Schedule
Here we will be only checking one example of each type of schedule:
If a schedule is view-equivalent it will be serializable.
If a schedule is view-serializable, it is also conflict serializable.
Blind writes are contained in the view serializable, which does not conflict with serializable.
View Equivalent
If two schedules, S1 and S2, meet the following criteria, they are said to be view equivalent:
Initial Read: Both schedules must have the same initial read. Assume S1 and S2 are two schedules. If a transaction T1 reads data item X in schedule S1, then transaction T1 in schedule S2 should also read X.
Schedule S1
T1
T2
read(X)
write(X)
Schedule S2
T1
T2
Read(X)
Write(X)
The schedules are view-equivalent as the initial read in S1 is done by T1 and S2.
Update Read: If Ti is reading A, which Tj updates in schedule S1, Ti should read A, which Tj edits in schedule S2.
Schedule S1
T1
T2
T3
Write(X)
Write(X)
Write(X)
Schedule S2
T1
T2
T3
Write(X)
Write(X)
Read(X)
Because T3 in S1 is reading A updated by T2 and T3 in S2 is reading A edited by T1, the two schedules are not equivalent.
Final Write: The final writing for both schedules must be the same. If a transaction T1 updates A last in schedule S1, T1 should also perform final writes operations in schedule S2.
Schedule S1
T1
T2
T3
Write(X)
Read(X)
Write(X)
Schedule S2
T1
T2
T3
Read(X)
Write(X)
Write(X)
Write(X)
Example
Let us check whether given schedule is view equivalent or not:
T1
T2
T3
Read(X)
Write(X)
Write(X)
Write(X)
Schedule S
A total number of possible schedules with three transactions are:
= 3!=6
S1 =<T1 T2 T3>
S2=<T1 T3 T2>
S3=<T2 T3 T1>
S4=<T2 T1 T3>
S5=<T3 T1 T2>
S6=<T3 T2 T1>
Considering the first schedule: Schedule S1
T1
T2
T3
Read(X)
Write(X)
Write(X)
Write(X)
Step 1: Final updation on data items
There is no read besides the first read in both schedules S and S1. Thus we don't need to check that condition.
Step 2: Initial Read
T1 performs the initial read operation in S, and T1 also in S1.
Step 3: Final Write
T3 performs the last write operation in S and T3 in S1. As a result, S and S1 are viewed as equivalent.
We don't need to verify another schedule because the first one, S1, meets all three criteria.
As a result, the comparable serial schedule is as follows:
What is View-Equivalent? Assume there are two schedules, S1 and S2. Suppose a transaction T1 in schedule S1 reads data item A. In that case, transaction T1 in schedule S2 should likewise read A. Because T1 performs the initial read operation in S1 and S2, the two schedules are comparable.
How do you know if a schedule is serializable? If a precedence graph has only one edge Ti Tj, then all of Ti's instructions are performed before the first instruction of Tj. Schedule S is non-serializable if its precedence graph comprises a cycle. S is serializable if the precedence graph does not have a process.
Why do we require serialization in a database management system? For the same 'n' number of transactions, serializable implies receiving an equivalent output as a serial schedule. Serializability ensures that a database's consistency and concurrency are maintained. Conflict equivalent and View equivalent are two extensively used approaches for determining serializability.
What is the difference between a serializable schedule and a serial schedule? Serial schedules are ones in which transactions are executed one after the other. When the operations are non-conflicting, a serializable schedule can be transformed into a serial schedule by exchanging the positions of operations from separate transactions.
Key takeaways
So Ninjas, in the article, we read about Schedules and saw its different types and one example of each. Then we saw what View-Serializable is, and after that, we saw the conditions for a schedule to view equivalent. Do not stop now and access some of the essential study materials here, Coding Ninjas Studio, and practice some critical questions here at the Top-100-SQL-problems.