Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
Schedules
3.
 
4.
 
5.
 
6.
 
7.
 
8.
View Seriable
8.1.
View Equivalent
8.2.
Example
9.
FAQs
10.
Key takeaways
Last Updated: Mar 27, 2024

Condition of Schedules to be View-Equivalent

Author Ankit Kumar
1 upvote
Master Python: Predicting weather forecasts
Speaker
Ashwin Goyal
Product Manager @

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:

  1. Serial Schedule
  2. Non-serial schedule
  3. Serializable Schedule

Here we will be only checking one example of each type of schedule:

  1. Serial Schedule
T1 T2

read(X);

X:=X-A;

write(x);

read(Y);

Y:=Y+B;

write(B)

 

 

 

 

 

 

read(X);

X:=X+A;

write(A);

 

  1. Non-serial schedule
T1 T2

read(X);

X:=X-N;

 

 

write(A);

read(B);

 

 

B:=B+N;

write(B);

 

 

read(X);

X:=X+M;

 

 

write(A);

 

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

 

 

 


 

 

 

 

Also Read - Cardinality In DBMS, Introduction of DBMS

View Seriable

  1. If a schedule is view-equivalent it will be serializable.
  2. If a schedule is view-serializable, it is also conflict serializable.
  3. 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:

  1. 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.

  1. 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.

  1. 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:

T1 -> T2 -> T3

You can also read about the Log based recovery.

Must Recommended Topic, Schema in DBMS

FAQs

  1. 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.
     
  2. 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.
     
  3. 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.
     
  4. 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.

Also read - multiple granularity in dbms

Previous article
Recoverability in DBMS
Next article
MOSS Concurrency Control Protocol
Live masterclass