Graph Based Concurrency Control Protocol in DBMS
Last Updated :
05 Feb, 2025
In a Database Management System (DBMS), multiple transactions often run at the same time, which can lead to conflicts when they access the same data. Graph-Based Concurrency Control Protocol helps manage these conflicts and ensures that the database remains consistent.
- In this protocol, transactions are represented as nodes in a graph, and conflicts between them are shown as edges.
- Before granting a lock on a data item, the system checks for cycles in the graph. If a cycle is detected, one of the transactions is rolled back to prevent deadlock and ensure smooth execution.
- A Graph-Based Protocol is a way of implementing Lock Based Protocols. It is deadlock free, but no guarantee of recoverability.
This method is more powerful than traditional locking techniques, as it can handle complex dependencies between transactions. However, it can be computationally expensive for large databases.
A prerequisite of this protocol is that we know the order to access a Database Item. For this, we implement a Partial Ordering on a set of the Database Items (D) {d1, d2, d3, ....., dn} . The protocol following the implementation of Partial Ordering is stated as-
- If di --> dj then any transaction accessing both di and dj must access di before accessing dj.
- Implies that the set D may now be viewed as a directed acyclic graph (DAG), called a database graph.
Tree Based Protocols is a simple implementation of Graph Based Protocol.
Tree Based Protocol
The Tree Protocol is a graph-based concurrency control method that ensures conflict serializability and deadlock freedom. Unlike Two-Phase Locking (2PL), it follows a hierarchical structure for locking data items.
Rules of Tree Protocol
- Only exclusive (X) locks are allowed – No shared (S) locks are used.
- The first lock can be on any data item – After that, a transaction can lock a data item only if it has locked its parent first.
- Data items can be unlocked at any time – There is no strict two-phase rule.
- No relocking – Once a transaction unlocks a data item, it cannot lock it again.
The Tree Protocol offers a balance between concurrency and deadlock prevention, making it useful in certain database applications.

Image - Database Graph
Let's look at an example based on the above Database Graph. We have three Transactions in this schedule and this is a skeleton example, i.e, we will only see how Locking and Unlocking work, let's keep this simple and not make this complex by adding operations on data.
| T1 | T2 | T3 |
---|
1 | Lock-X(A) | | |
---|
2 | Lock-X(B) | | |
---|
3 | | Lock-X(D) | |
---|
4 | | Lock-X(H) | |
---|
5 | | Unlock-X(D) | |
---|
6 | Lock-X(E) | | |
---|
7 | Lock-X(D) | | |
---|
8 | Unlock-X(B) | | |
---|
9 | Unlock-X(E) | | |
---|
10 | | | Lock-X(B) |
---|
11 | | | Lock-X(E) |
---|
12 | | Unlock-X(H) | |
---|
13 | Lock-X(B) | | |
---|
14 | Lock-X(G) | | |
---|
15 | Unlock-X(D) | | |
---|
16 | | | Unlock-X(E) |
---|
17 | | | Unlock-X(B) |
---|
18 | Unlock-X(G) | | |
---|
From the above example, first see that the schedule is Conflict Serializable. Serializability for Locks can be written as T2 --> T1 --> T3.
Data items Locked and Unlocked are following the same rule as given above and follow the Database Graph.
Advantages of Tree Protocol
- Deadlock-free – No cycles form in the lock order, so no rollbacks are needed.
- Increased concurrency – Unlocking can happen earlier than in Two-Phase Locking, reducing wait times.
- Allows different schedules – Some schedules that are not possible under 2PL can be executed under the tree protocol.
Drawbacks of Tree Protocol
- No guarantee of recoverability – Can lead to cascading rollbacks if not handled properly.
- Extra locks required – Transactions may need to lock unnecessary data items, increasing waiting time and locking overhead.
- Some schedules allowed in 2PL are not possible in Tree Protocol – While it provides flexibility, it also has limitations.
FAQs on Graph-Based Concurrency Control Protocol in DBMS
What is Graph-Based Concurrency Control in DBMS?
Graph-Based Concurrency Control is a method that represents transactions as nodes in a directed graph, with edges showing conflicts when transactions access the same data. It ensures consistency by detecting cycles and resolving conflicts.
How does the Graph-Based Concurrency Control Protocol prevent deadlocks?
It prevents deadlocks by ensuring that transactions follow a predefined partial order when accessing data items, forming a Directed Acyclic Graph (DAG). If a cycle is detected, a transaction is rolled back to maintain serializability.
What is the role of partial ordering in Graph-Based Concurrency Control?
A partial order is imposed on data items, meaning if a transaction accesses a set of items, it must access them in a specific order. This ensures a structured execution pattern and prevents cyclic dependencies.
How does the Tree Protocol relate to Graph-Based Concurrency Control?
The Tree Protocol is a type of graph-based concurrency control where transactions acquire exclusive locks following a hierarchical structure. This prevents deadlocks but may require transactions to lock unused data, increasing overhead.
What are the advantages and limitations of Graph-Based Concurrency Control?
It efficiently manages complex dependencies and eliminates deadlocks but can be computationally expensive and less scalable for large databases with many concurrent transactions. The need for predefined ordering can also reduce flexibility.
Similar Reads
SQL Commands | DDL, DQL, DML, DCL and TCL Commands SQL commands are crucial for managing databases effectively. These commands are divided into categories such as Data Definition Language (DDL), Data Manipulation Language (DML), Data Control Language (DCL), Data Query Language (DQL), and Transaction Control Language (TCL). In this article, we will e
7 min read
DBMS Tutorial â Learn Database Management System Database Management System (DBMS) is a software used to manage data from a database. A database is a structured collection of data that is stored in an electronic device. The data can be text, video, image or any other format.A relational database stores data in the form of tables and a NoSQL databa
7 min read
Introduction of ER Model The Entity-Relationship Model (ER Model) is a conceptual model for designing a databases. This model represents the logical structure of a database, including entities, their attributes and relationships between them. Entity: An objects that is stored as data such as Student, Course or Company.Attri
10 min read
TCP/IP Model The TCP/IP model is a framework that is used to model the communication in a network. It is mainly a collection of network protocols and organization of these protocols in different layers for modeling the network.It has four layers, Application, Transport, Network/Internet and Network Access.While
7 min read
Operating System Tutorial An Operating System(OS) is a software that manages and handles hardware and software resources of a computing device. Responsible for managing and controlling all the activities and sharing of computer resources among different running applications.A low-level Software that includes all the basic fu
4 min read
Computer Network Tutorial A Computer Network is a system where two or more devices are linked together to share data, resources and information. These networks can range from simple setups, like connecting two devices in your home, to massive global systems, like the Internet. Below are the main components of a computer netw
7 min read
Basics of Computer Networking A computer network is a collection of interconnected devices that share resources and information. These devices can include computers, servers, printers, and other hardware. Networks allow for the efficient exchange of data, enabling various applications such as email, file sharing, and internet br
14 min read
Normal Forms in DBMS In the world of database management, Normal Forms are important for ensuring that data is structured logically, reducing redundancy, and maintaining data integrity. When working with databases, especially relational databases, it is critical to follow normalization techniques that help to eliminate
7 min read
ACID Properties in DBMS In the world of DBMS, transactions are fundamental operations that allow us to modify and retrieve data. However, to ensure the integrity of a database, it is important that these transactions are executed in a way that maintains consistency, correctness, and reliability. This is where the ACID prop
8 min read
Java Programs - Java Programming Examples In this article, we will learn and prepare for Interviews using Java Programming Examples. From basic Java programs like the Fibonacci series, Prime numbers, Factorial numbers, and Palindrome numbers to advanced Java programs.Java is one of the most popular programming languages today because of its
8 min read