Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Notes  >  Database Management System (DBMS)  >  Precedence Graph For Testing Conflict Serializability

Precedence Graph For Testing Conflict Serializability | Database Management System (DBMS) - Computer Science Engineering (CSE) PDF Download

Precedence Graph For Testing Conflict Serializability in DBMS

Precedence Graph or Serialization Graph is used commonly to test Conflict Serializability of a schedule.
It is a directed Graph (V, E) consisting of a set of nodes V = {T1, T2, T3……….Tn} and a set of directed edges E = {e1, e2, e3………………em}.
The graph contains one node for each Transaction Ti. An edge ei is of the form Tj → Tk where Tj is the starting node of ei and Tk is the ending node of ei. An edge ei is constructed between nodes Tj to Tk if one of the operations in Tj appears in the schedule before some conflicting operation in Tk .

The Algorithm can be written as:

  1. Create a node T in the graph for each participating transaction in the schedule.
  2. For the conflicting operation read_item(X) and write_item(X) – If a Transaction Tj executes a read_item (X) after Ti executes a write_item (X), draw an edge from Ti to Tj in the graph.
  3. For the conflicting operation write_item(X) and read_item(X) – If a Transaction Tj executes a write_item (X) after Ti executes a read_item (X), draw an edge from Ti to Tj in the graph.
  4. For the conflicting operation write_item(X) and write_item(X) – If a Transaction Tj executes a write_item (X) after Ti executes a write_item (X), draw an edge from Ti to Tj in the graph.
  5. The Schedule S is serializable if there is no cycle in the precedence graph.

If there is no cycle in the precedence graph, it means we can construct a serial schedule S’ which is conflict equivalent to the schedule S.
The serial schedule S’ can be found by Topological Sorting of the acyclic precedence graph. Such schedules can be more than 1.
For example,
Consider the schedule S:
S : r1(x) r1(y) w2(x) w1(x) r2(y)

Creating Precedence graph:

  1. Make two nodes corresponding to Transaction T1 and T2.
    Precedence Graph For Testing Conflict Serializability | Database Management System (DBMS) - Computer Science Engineering (CSE)
  2. For the conflicting pair r1(x) w2(x), where r1(x) happens before w2(x), draw an edge from T1 to T2.
    Precedence Graph For Testing Conflict Serializability | Database Management System (DBMS) - Computer Science Engineering (CSE)
  3. For the conflicting pair w2(x) w1(x), where w2(x) happens before w1(x), draw an edge from T2 to T1.
    Precedence Graph For Testing Conflict Serializability | Database Management System (DBMS) - Computer Science Engineering (CSE)Since the graph is cyclic, we can conclude that it is not conflict serializable to any schedule serial schedule.
    Let us try to infer a serial schedule from this graph using topological ordering.
    The edge T1 → T2 tells that T1 should come before T2 in the linear ordering.
    The edge T2 → T1 tells that T2 should come before T1 in the linear ordering.
    So, we can not predict any particular order (when the graph is cyclic). Therefore, no serial schedule can be obtained from this graph.
    Consider the another schedule S1 :
    S1: r1(x) r3(y) w1(x) w2(y) r3(x) w2(x)
    The graph for this schedule is:Precedence Graph For Testing Conflict Serializability | Database Management System (DBMS) - Computer Science Engineering (CSE)Since the graph is acyclic, the schedule is conflict serializable. Performing Topological Sort on this graph would give us a possible serial schedule which is conflict equivalent to schedule S1.
    In Topological Sort, we first select the node with indegree 0, which is T1. This would be followed by T3 and T2.
    So, S1 is conflict serializable since it is conflict equivalent to the serial schedule T1 T3 T2.

Condition of schedules to View-equivalent

Two schedules S1 and S2 are said to be view-equivalent if below conditions are satisfied: 

  1. Initial Read
    If a transaction T1 reading data item A from database in S1 then in S2 also T1 should read A from database.
    Precedence Graph For Testing Conflict Serializability | Database Management System (DBMS) - Computer Science Engineering (CSE)Transaction T2 is reading A from database. 
  2. Updated Read 
    If Ti is reading A which is updated by Tj in S1 then in S2 also Ti should read A which is updated by Tj.
    Precedence Graph For Testing Conflict Serializability | Database Management System (DBMS) - Computer Science Engineering (CSE)Above two schedule are not view-equivalent as in S1 : T3 is reading A updated by T2, in S2 T3 is reading A updated by T1. 
  3. Final Write operation 
    If a transaction T1 updated A at last in S1, then in S2 also T1 should perform final write operations.
    Precedence Graph For Testing Conflict Serializability | Database Management System (DBMS) - Computer Science Engineering (CSE) Above two schedules are not view-equivalent as Final write operation in S1 is done by T1 while in S2 done by T2.

View Serializability: A Schedule is called view serializable if it is view equal to a serial schedule (no overlapping transactions). 

The document Precedence Graph For Testing Conflict Serializability | Database Management System (DBMS) - Computer Science Engineering (CSE) is a part of the Computer Science Engineering (CSE) Course Database Management System (DBMS).
All you need of Computer Science Engineering (CSE) at this link: Computer Science Engineering (CSE)
62 videos|66 docs|35 tests

Top Courses for Computer Science Engineering (CSE)

62 videos|66 docs|35 tests
Download as PDF
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

past year papers

,

Important questions

,

Objective type Questions

,

mock tests for examination

,

video lectures

,

study material

,

Extra Questions

,

Precedence Graph For Testing Conflict Serializability | Database Management System (DBMS) - Computer Science Engineering (CSE)

,

pdf

,

shortcuts and tricks

,

Summary

,

practice quizzes

,

Semester Notes

,

Viva Questions

,

Previous Year Questions with Solutions

,

MCQs

,

ppt

,

Free

,

Exam

,

Precedence Graph For Testing Conflict Serializability | Database Management System (DBMS) - Computer Science Engineering (CSE)

,

Precedence Graph For Testing Conflict Serializability | Database Management System (DBMS) - Computer Science Engineering (CSE)

,

Sample Paper

;