Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Aptitude
  • Engineering Mathematics
  • Discrete Mathematics
  • Operating System
  • DBMS
  • Computer Networks
  • Digital Logic and Design
  • C Programming
  • Data Structures
  • Algorithms
  • Theory of Computation
  • Compiler Design
  • Computer Org and Architecture
Open In App
Next Article:
Polygraph to check View Serializability in DBMS
Next article icon

Polygraph to check View Serializability in DBMS

Last Updated : 07 Feb, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

In a Database Management System (DBMS), ensuring that transactions execute correctly without conflicts is important. One way to check this is through view serializability, which ensures that a schedule produces the same final result as some serial execution of transactions.

To check view serializability, we use a polygraph, a special type of graph that helps to visualize dependencies between transactions. By analyzing this graph, we can determine whether a given schedule maintains the correct order of operations.

Note: The main objective of serializability is to identify non-serial schedules that allow transactions to execute concurrently without interference while ensuring that the final database state is equivalent to a serial execution (where transactions run one after another).

There are different types of schedules based on serializability:

  1. Serial Schedule – Transactions execute one after another without overlapping.
  2. Non-Serial Schedule – Transactions overlap in execution.
  3. Conflict Serializable Schedule – A non-serial schedule that can be converted into a serial schedule by swapping non-conflicting operations.
  4. View Serializable Schedule – A non-serial schedule that produces the same final database state as some serial schedule, but may not be conflict serializable.

View Serializability

views

A schedule is called View Serializable if it's view equivalent to a serial schedule (no overlapping transaction allowed). For a schedule to be View Serializable, it must meet these three conditions:

  1. Same Initial Reads – Each transaction in the schedule must read the same initial values as in a serial schedule.
  2. Same Read-Write Mapping – If a transaction reads a value written by another transaction, it must be the same as in a serial schedule.
  3. Same Final Writes – The final write operations in both schedules must be the same.

Now, let us consider the following examples. 

Example: Suppose there is two schedules one is non-serial and another one is serial schedule.  

    Schedule 1              Schedule 2      
-------------- ---------------
T1 T2 T1 T2
-------------- ---------------
r1(A) r1(A)
A=A+10 A=A+10
w1(A) w1(A)
r1(B) r2(A)
B=B*10 A=A+10
w1(B) w2(a)
r2(A) r1(B)
A=A+10 B=B*10
w2(A) w2(B)
r2(B) r2(B)
B=B*10 B=B*10
w2(B) w2(B)


To check whether the given Schedule 1 and Schedule 2 are View Serializable, we need to verify the three conditions of View Serializability:

  • Same Initial Reads: Both schedules ensure that transactions read the initial values of A and B in the same way.
  • Same Read-Write Mapping: In both schedules, transactions read values written by previous transactions consistently.
  • Same Final Writes: The final values of A and B in both schedules match what would happen in some serial execution of T1 and T2.

Since both schedules follow the three conditions of View Serializability, they are View Serializable.

Polygraph Method to check View Serializability

Polygraph is a graphical representation used to check view serializability in database management systems (DBMS). View serializability is a property of a schedule of transactions that ensures the same final result is obtained regardless of the order in which the transactions are executed.

A polygraph consists of a directed graph with each node representing a transaction in the schedule, and each edge representing a conflict between two transactions. A conflict occurs when two transactions try to access the same data item in different ways, such as one reading and the other writing, or both writing.

To construct a polygraph, the following steps are followed:

  1. Identify all the transactions in the schedule.
  2. For each pair of transactions Ti and Tj, determine if there is a conflict between them. If there is a conflict, draw a directed edge from Ti to Tj.
  3. If there is a cycle in the polygraph, the schedule is not viewed as serializable, and the transactions must be rearranged to ensure view serializability.
  4. To check if a schedule is view serializable using a polygraph, we need to ensure that there are no cycles in the polygraph. If there are no cycles, the schedule is view serializable, and we can execute the transactions in any order without changing the final result.

Using polygraph when the number of transactions is more than 2 : Suppose we have 3 transactions T1, T2 and T3. Possible combinations of those transactions are:  

 T1   T2   T3
T1 T3 T2
T2 T1 T3
T2 T3 T1
T3 T1 T2
T3 T2 T1

1. A Tn reads an initial data in a schedule the same Tn also should read the initial data in one of the transaction combinations. That means T1 should occur before T2, so we have to remove these combinations: 

 T2   T1   T3
T2 T3 T1
T3 T2 T1

2. If a transaction (Tn) reads a value that was written by another transaction (Tm) in a schedule, then in any equivalent serial schedule, Tn should read the same value after Tm writes it. 

3. A Tn writes the final value for a data in a schedule, the same Tn should also write the final data in one of the transaction combinations. That means T2 occur before T3, so we have to remove these combinations: 

 T1   T3   T2
T3 T1 T2

Remaining Schedule: T1 → T2 → T3

Polygraph Construction

If the polygraph is acyclic, then the schedule T1 → T2 → T3 is View Serializable.

view
Polygraph

Advantages

Accuracy: Polygraph is a powerful tool that can accurately determine whether a schedule is view serializable or not. It can detect conflicts that may not be apparent from a manual analysis of the schedule.

Efficiency: Polygraph can quickly analyze large schedules and determine whether they are view serializable. This saves time and effort that would be required for a manual analysis.

Visualization: Polygraph generates a graph representation of the schedule that shows the dependencies between transactions. This visualization can help users to better understand the schedule and the conflicts that occur.

Flexibility: Polygraph can be used to check the view serializability of different types of schedules, including serial and concurrent schedules.

Disadvantages

Complexity: Polygraph is a complex tool that requires a high level of technical expertise to use effectively. Users must be familiar with graph theory and database concepts to interpret the results.

Limited scope: Polygraph is designed to check view serializability only. It cannot detect other types of anomalies, such as deadlock or starvation.

False negatives: Polygraph may fail to detect some instances of non-view serializable schedules, resulting in false negatives.

Limited applicability: Polygraph may not be useful for all types of databases or database systems. Some DBMSs may have built-in features that ensure view serializability, making polygraph redundant.

FAQs on Polygraph to Check View Serializability in DBMS

What is a Polygraph in DBMS?

A Polygraph is a directed graph used to check View Serializability in DBMS by representing dependencies between transactions based on read-write and write-write relationships.

How does a Polygraph help in checking View Serializability?

A Polygraph helps by visually representing transaction dependencies. If the graph contains a cycle, the schedule is not view serializable. If no cycle exists, the schedule is view serializable and can be executed in some serial order.

What is the difference between a Polygraph and a Precedence Graph?

A Precedence Graph is used to check Conflict Serializability, ensuring a strict transaction order based on conflicts. A Polygraph is more flexible and is used to check View Serializability, allowing more schedules to be considered valid.

What are the steps to construct a Polygraph for a given schedule?

Identify transactions and dependencies, draw directed edges for read-after-write and write-after-write relationships, and check for cycles. If there are no cycles, the schedule is view serializable.

What happens if a cycle is found in the Polygraph?

A cycle means that no equivalent serial schedule exists for the given schedule, so it is not view serializable. Transactions may need to be reordered or rescheduled to achieve serializability.


Next Article
Polygraph to check View Serializability in DBMS

S

Sabya_Samadder
Improve
Article Tags :
  • DBMS
  • GATE CS
  • Technical Scripter 2018
  • DBMS-Transactions and Concurrency Control

Similar Reads

    View Serializability in DBMS
    In database systems, concurrent execution of transactions is used to improve resource utilization and system throughput. However, concurrency can lead to inconsistencies in the database if not handled properly.View Serializability ensures that even though transactions run concurrently, their outcome
    6 min read
    Serializability in DBMS
    In this article, we are going to explain the serializability concept and how this concept affects the DBMS deeply, we also understand the concept of serializability with some examples, and we will finally conclude this topic with an example of the importance of serializability. The DBMS form is the
    9 min read
    Conflict Serializability in DBMS
    A schedule is a sequence in which operations (read, write, commit, abort) from multiple transactions are executed in a database. Serial or one by one execution of schedules has less resource utilization and low throughput. To improve it, two or more transactions are run concurrently. Conflict Serial
    5 min read
    Result Serializability in DBMS
    Prerequisite - Serializable Schedules Equivalence of Schedules : A schedule is a way of representing the order in which the operations of transactions get executed. Based on different properties related to the schedules such as end result, the order of execution of transactions two schedules might b
    2 min read
    Materialization View in DBMS
    A materialization view is nothing but a snapshot or materialized query table. It is a database object that stores the results of the query table. Materialized views in the Database Management System (DBMS) work as the existing snapshots of the data, reducing the computational overhead. Unlike standa
    6 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences