0% found this document useful (0 votes)
139 views18 pages

Problems On View Serializability

Here you'll find problem on view serializability

Uploaded by

beast boy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
139 views18 pages

Problems On View Serializability

Here you'll find problem on view serializability

Uploaded by

beast boy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Practice Problems on View

Serializability
Dr. Bidyut Das, Department of Information Technology,
Haldia Institute of Technology, Haldia
View Serializability
• If a given schedule is found to be view equivalent to some serial
schedule, then it is called as a view serializable schedule.

View Equivalent Schedules (s1,s2):


1. Initial readers must be same for all the data items
2. Write-read sequence must be same.
3. Final writers must be same for all the data items.

Dr. Bidyut Das, Department of Information Technology, Haldia


Institute of Technology, Haldia
Checking Whether a Schedule is View Serializable
Or Not-
• If the given schedule is conflict serializable, then it is surely view
serializable. (All conflict serializable schedules are view serializable.)
• If the given schedule is not conflict serializable, then it may or may not be
view serializable. (All view serializable schedules may or may not be
conflict serializable.)
• If there does not exist any blind write, then the schedule is surely not view
serializable. (Writing without reading is called as a blind write).
• If there exists any blind write, then the schedule may or may not be view
serializable.
• Then, draw a dependency graph. If there exists no cycle in the graph, then
the schedule is view serializable otherwise not.

Dr. Bidyut Das, Department of Information Technology, Haldia


Institute of Technology, Haldia
View Serializability

Dr. Bidyut Das, Department of Information Technology, Haldia


Institute of Technology, Haldia
View Serializability in DBMS | Practice Problems
Problem-01: Check whether the given schedule S is view serializable or
not-

Dr. Bidyut Das, Department of Information Technology, Haldia


Institute of Technology, Haldia
Solution:
• We know, if a schedule is conflict serializable, then it is surely view
serializable.
• So, let us check whether the given schedule is conflict serializable or
not.

Checking Whether S is Conflict Serializable Or Not-


Step-01: List all the conflicting operations and determine the
dependency between the transactions:

Dr. Bidyut Das, Department of Information Technology, Haldia


Institute of Technology, Haldia
Solution (Contd.)
W1(B) , W2(B) (T1 → T2)
W1(B) , W3(B) (T1 → T3)
W1(B) , W4(B) (T1 → T4)
W2(B) , W3(B) (T2 → T3)
W2(B) , W4(B) (T2 → T4)
W3(B) , W4(B) (T3 → T4)
Step-02: Draw the precedence graph:
• Clearly, there exists no cycle in the precedence graph.
• Therefore, the given schedule S is conflict serializable.
• Thus, we conclude that the given schedule is also view serializable.
Dr. Bidyut Das, Department of Information Technology, Haldia
Institute of Technology, Haldia
Problem-02: Check whether the given schedule S is view serializable or
not-

Solution:
• If a schedule is conflict serializable, then it is surely view
serializable.
• So, let us check whether the given schedule is conflict serializable
or not. Dr. Bidyut Das, Department of Information Technology, Haldia
Institute of Technology, Haldia
Solution (Contd.):
Checking Whether S is Conflict Serializable Or Not:
Step-01:
List all the conflicting operations and determine the dependency between the
transactions:
R1(A) , W3(A) (T1 → T3) Step-02: Draw the precedence graph:
R2(A) , W3(A) (T2 → T3)
R2(A) , W1(A) (T2 → T1)
W3(A) , W1(A) (T3 → T1)

• Clearly, there exists a cycle in the precedence graph.


• Therefore, the given schedule S is not conflict serializable.
Dr. Bidyut Das, Department of Information Technology, Haldia
Institute of Technology, Haldia
Solution (Contd.):
• Since, the given schedule S is not conflict serializable, so, it may or
may not be view serializable.
• To check whether S is view serializable or not, let us use another
method.
Let us check for blind writes.
• There exists a blind write W3 (A) in the given schedule S.
• Therefore, the given schedule S may or may not be view serializable.

Dr. Bidyut Das, Department of Information Technology, Haldia


Institute of Technology, Haldia
Solution (Contd.):
• Now, To check whether S is view serializable or not, let us use another method.
• Let us derive the dependencies and then draw a dependency graph.

• T1 firstly reads A and T3 firstly updates A.


• So, T1 must execute before T3.
• Thus, we get the dependency T1 → T3.
• Final update on A is made by the transaction T1.
• So, T1 must execute after all other transactions.
• Thus, we get the dependency (T2, T3) → T1.
• There exists no write-read sequence.

• Clearly, there exists a cycle in the dependency graph.


• Thus, we conclude that the given schedule S is not view serializable.
Dr. Bidyut Das, Department of Information Technology, Haldia
Institute of Technology, Haldia
Problem-03: Check whether the given schedule S is view
serializable or not:
Solution:
• We know, if a schedule is conflict serializable, then it is surely
view serializable.
• So, let us check whether the given schedule is conflict serializable
or not.
Checking Whether S is Conflict Serializable Or Not-
Step-01:
List all the conflicting operations and determine the dependency
between the transactions:
R1(A) , W2(A) (T1 → T2)
R2(A) , W1(A) (T2 → T1)
W1(A) , W2(A) (T1 → T2)
R1(B) , W2(B) (T1 → T2)
R2(B) , W1(B) (T2 → T1)
Dr. Bidyut Das, Department of Information Technology, Haldia
Institute of Technology, Haldia
Solution (Contd.):
Step-02: Draw the precedence graph:

• Clearly, there exists a cycle in the precedence graph.


• Therefore, the given schedule S is not conflict serializable.
• Since, the given schedule S is not conflict serializable, so, it may or may not be view
serializable.
• Let us check for blind writes.

Checking for Blind Writes:

• There exists no blind write in the given schedule S.


• Therefore, it is surely not view serializable.
Dr. Bidyut Das, Department of Information Technology, Haldia
Institute of Technology, Haldia
Problem-04: Check whether the given schedule S is view serializable or not. If yes,
then give the serial schedule.
S : R1(A) , W2(A) , R3(A) , W1(A) , W3(A)

Solution: For simplicity and better understanding, we can represent the


given schedule pictorially as-

• If a schedule is conflict serializable, then it is surely view serializable.


Dr. Bidyut Das, Department of Information Technology, Haldia
Institute of Technology, Haldia
Solution (Contd.): Checking Whether S is Conflict Serializable
Or Not:
Step-01: List all the conflicting operations and determine the dependency between
the transactions:
R1(A) , W2(A) (T1 → T2) Step-02: Draw the precedence graph:
R1(A) , W3(A) (T1 → T3)
W2(A) , R3(A) (T2 → T3)
W2(A) , W1(A) (T2 → T1)
W2(A) , W3(A) (T2 → T3)
R3(A) , W1(A) (T3 → T1) • Clearly, there exists a cycle in the precedence graph.
• Therefore, the given schedule S is not conflict serializable
W1(A) , W3(A) (T1 → T3) and may or may not be view serializable.
• To check whether S is view serializable or not, let us use
blind writes.
Dr. Bidyut Das, Department of Information Technology, Haldia
Institute of Technology, Haldia
Solution (Contd.):
Checking for Blind Writes-
• There exists a blind write W2 (A) in the given schedule S.
• Therefore, the given schedule S may or may not be view serializable.

Now,
• To check whether S is view serializable or not, let us use another
method.
• Let us derive the dependencies and then draw a dependency graph.

Dr. Bidyut Das, Department of Information Technology, Haldia


Institute of Technology, Haldia
Solution (Contd.): Dependency graph
• T1 firstly reads A and T2 firstly updates A.
• So, T1 must execute before T2.
• Thus, we get the dependency T1 → T2.
• Final update on A is made by the transaction T3.
• So, T3 must execute after all other transactions.
• Thus, we get the dependency (T1, T2) → T3.
• From write-read sequence, we get the dependency
T2 → T3

• Clearly, there exists no cycle in the dependency graph.


• Therefore, the given schedule S is view serializable.
• The serialization order T1 → T2 → T3.

Dr. Bidyut Das, Department of Information Technology, Haldia


Institute of Technology, Haldia
Thanks for your attention.

Dr. Bidyut Das, Department of Information Technology, Haldia


Institute of Technology, Haldia

You might also like