Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
What is Serializability in DBMS?
3.
Serializable Schedule in DBMS
4.
Types of Schedules in DBMS
4.1.
Serial schedule
4.1.1.
Example
4.2.
Non-serial schedule
4.2.1.
Example
5.
Types of Serializability in DBMS
5.1.
Conflict Serializability
5.1.1.
Example
5.2.
View Serializability
5.2.1.
Example
6.
Testing of Serializability in DBMS with Examples
6.1.
Precedence Graph Method 
6.2.
Conflict Serializability Method
7.
Advantages of Serializability in DBMS
8.
Disadvantages of Serializability in DBMS
9.
Frequently Asked Questions
9.1.
What is DBMS schedule?
9.2.
What is serializability in DBMS?
9.3.
What is serializability of a class?
9.4.
Why is serializability important in DBMS?
9.5.
What are the types of serializability in DBMS?
9.6.
What is serializability and scheduling in DBMS?
10.
Conclusion
Last Updated: Mar 27, 2024
Medium

Serializability in DBMS

Author Pallavi singh
1 upvote
Master Python: Predicting weather forecasts
Speaker
Ashwin Goyal
Product Manager @

Introduction

In this article, we will discuss the serializability schedule in DBMS. We will also discuss the types of serializability and some examples to understand serializability in DBMS. 

Before moving on to the topic, let us first understand what a schedule is in DBMS.

serializability in dbms

What is Serializability in DBMS?

Serializability in DBMS ensures safe parallel execution of transactions by enforcing rules, preventing unexpected or incorrect results. Each transaction is treated as if it's the only one running, maintaining integrity.

DBMS employs a technique called concurrency control to achieve serializability. This technique helps ensure that multiple transactions do not interfere with each other's execution by controlling their access to shared resources. These shared resources can be database tables and records. By maintaining serializability, the DBMS ensures the correctness and consistency of the database even under heavy concurrent usage. 

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

Serializable Schedule in DBMS

A serializability schedule in DBMS ensures that concurrent transactions produce the same final result as if they were executed one after the other. It also helps to maintain the data consistency and integrity.

It is important because it maintains the ACID (Atomicity, Consistency, Isolation and Durability) property of any Database. It also makes sure that the final state of a database is consistent. We will further look at the types and methods to check serializability in any schedule.

Also read, File System vs DBMS

Types of Schedules in DBMS

There are two types of schedules in DBMS:

Serial schedule

These are those schedules in which transactions are executed sequentially, meaning a new transaction doesn't begin until the previous one has concluded.

Example

Transaction Operation
T1 Read(X)
T1 Write(X)
T2 Read(Y)
T2 Write(Y)

Non-serial schedule

This scheduling method involves interleaving the operations of multiple transactions, potentially increasing concurrency challenges. Transactions are executed concurrently, yet the final outcome remains consistent and identical to a serial schedule. It is further divided into two parts:

  1. Serializable(Conflict and View Serializable)
  2. Non- serializable(Recoverable and Non-recoverable)
     

Example

Transaction Operation
T1 Read(X)
T2 Read(Y)
T1 Write(X)
T2 Write(Y)

Types of Serializability in DBMS

In DBMS (Database Management System), there are two types of serializability:

  1. Conflict Serializability
     
  2. View Serializability

Conflict Serializability

Conflict serializability is a property of a schedule. It ensures that it is equivalent to a serial schedule. A schedule can be declared as conflict serializable if and only if all conflicting pairs of transactions in the schedule have the same relative order in all serial schedules that are equivalent to the given schedule.

conflicting pair of transactions is a pair of transactions that access the same data item, and at least one of them is a write operation. This type of serializability can be determined by drawing a precedence graph of the transactions in the schedule and checking if the graph is acyclic. If the graph is acyclic, then the schedule is conflict serializable. If it contains a cycle, then the schedule is not conflict serializable.

Let us understand this with an example.

Example

Consider a schedule with three transactions, T1, T2, and T3, and the following set of operations:

T1: R(P), W(Q)
T2: R(Q), W(R)
T3: R(R), W(P)

 

The operations that are performed in the transactions are R(Read) and W(Write) operations on the data items ‘P’ and ‘Q’.

In a precedence graph, the edges represent the ordering constraints between transactions in the concurrent execution of a database system. If we encounter any conflicts between transactions, then we will draw an edge. The conflict serializability of the schedule can be determined by constructing a precedence graph as follows:

T1 -> T2
T2 -> T3
T3 -> T1
precedence graph in conflict serializable

The graph has a cycle (T1 -> T2 -> T3 -> T1), indicating that the schedule is not conflict serializable.

View Serializability

View serializability is a property of a schedule. It ensures that it is equivalent to a serial schedule with the same set of read and write operations. A schedule is declared as view serializable if and only if it produces the same set of values for all read operations as any serial schedule that is equivalent to the given schedule.

View serializability can be determined by constructing a view serializable schedule graph (VSG) of the transactions in the schedule. The VSG contains nodes representing the transactions and edges representing conflicts and views between the transactions. If the VSG is acyclic, then the schedule is view serializable.

Let us understand this with an example.

Example

Consider a schedule with three transactions, T1, T2, and T3, and the following set of operations:

T1: R(P), W(Q)
T2: R(Q), W(R)
T3: R(R), W(P)

 

The operations that are performed in the transactions are R(Read) and W(Write) operations on the data items ‘P’ and ‘Q’. In a VSG, the edges represent the ordering constraints between transactions in the concurrent execution of a database system. It ensures that the transactions are view serializable.

We must first identify the view equivalent schedules for the given concurrent execution to obtain the edges in this graph. Two schedules are view equivalent if they produce the same set of database states for any initial database state.  The view serializability of the schedule can be determined by constructing a VSG as follows:

T1 -> T2
T2 -> T3
T3 -> T1
view serializability graph in view serializable

The VSG has a cycle (T1 -> T2 -> T3 -> T1), indicating that the schedule is not view serializable.

Note that a schedule that is conflict serializable is always view serializable, but vice-versa may not be true.

Testing of Serializability in DBMS with Examples

Testing serializability in DBMS is very important as it maintains the accuracy and stability of multiple simultaneous transactions. There are two methods of testing serializability in DBMS: the precedence graph method and the serialization graph method. Let us look at how we can test serializability in DBMS.

Precedence Graph Method 

Let us take an example and test serializability with a step-by-step process.

Consider a schedule with three transactions, T1, T2, and T3, and the following set of operations:

T1: R(A), W(B)
T2: W(A), R(B)
T3: R(B), W(A)


Step 1: Firstly, we will create a precedence graph.

T1 -> T2
T2 -> T3
T3 -> T1


Step 2: In this step, we will check the presence of the cycle in the graph. If there is no cycle, then the schedule is serializable.

In the example, T1 -> T2 -> T3 -> T1 makes up a cycle, so the schedule is not serializable.

Conflict Serializability Method

This method checks for the conflict between write and read operations. Let us take the example shown for the above method and test serializability with a step-by-step process.

T1: R(A), W(B)
T2: W(A), R(B)
T3: R(B), W(A)


Step 1: we will look for the pairs of conflicting operations in this step.

T1 and T2 conflict on (R(A), W(A))
T2 and T3 conflict on (R(B), W(A))


Step 2: If there is no conflict, then the schedule is serializable; otherwise, we would need to do some other analysis to find out the serializability.

There is a conflict between T1 and T2, T2 and T3, so the schedule is not serializable.

Advantages of Serializability in DBMS

The advantages of serializability in DBMS are:

  • It ensures that the final state of the database is consistent, regardless of checking the order in which transactions are executed. It prevents data inconsistencies and anomalies that can occur when multiple transactions try to access and modify the same data concurrently.
     
  • By ensuring consistency, serializability improves the reliability of the database. 
     
  • It is the basis of concurrency control in DBMS. It ensures that multiple transactions can access and modify the same data without interfering with each other's operations. 
     
  • A serializable database can scale to handle large amounts of data and high transaction volumes. 
     
  • Many regulatory frameworks require serializability in database transactions to ensure data accuracy, privacy, and security. 

Also read anomalies in database

Disadvantages of Serializability in DBMS

While serializability has many advantages in DBMS, there are also some disadvantages:

  • It imposes strict ordering constraints on transactions. This can reduce concurrency and slow down the processing of transactions. This can result in longer wait times and decreased system performance.
     
  • Implementing serializability requires additional overhead, including transaction management, locking, and logging. This can increase the complexity and cost of the database system.
     
  • The use of locking mechanisms to enforce serializability can lead to deadlocks.
     
  • When a transaction executes, the resources it has acquired, such as locks on database objects, may be unavailable to other transactions, causing them to wait. This can reduce the system's availability, especially under high transaction loads.
     
  • It can lead to poor performance if transactions frequently access the same data items. This is due to locking mechanisms used to ensure serializability can cause contention for resources, leading to delays and increased processing time.

Also read - multiple granularity in dbms
 

Frequently Asked Questions

What is DBMS schedule?

A DBMS schedule is an ordered sequence of operations performed by transactions, determining the order in which transactions access and modify data in the database.

What is serializability in DBMS?

Serializability is a property of a schedule of transactions in a DBMS that ensures that the database remains consistent and correct even when multiple transactions execute concurrently.

What is serializability of a class?

Serializability of a class ensures that only one operation can access the class at a time, maintaining data consistency and preventing conflicts in concurrent access.

Why is serializability important in DBMS?

Serializability in DBMS ensures that multiple transactions can access and modify the same data without interfering with each other's operations. It helps to prevent data inconsistencies and anomalies that can occur when multiple transactions try to access and modify the same data concurrently.

What are the types of serializability in DBMS?

There are two types of serializability in DBMS that are conflict serializability and view serializability. Conflict serializability ensures that the result of any execution of the transactions is the same as the result of executing them in some serial order. View serializability ensures that any view of the database that can be obtained by executing the transactions in some serial order is the same as the view that can be obtained by executing them concurrently.

What is serializability and scheduling in DBMS?

In Serializability, multiple transactions produce the same results as if they were executed in sequential order. While Scheduling refers to the order in which the transactions are executed. 

Conclusion

This article delves into the concept of serializability schedule in DBMS. We have also discussed the schedule and some examples to understand serializability in DBMS. Additionally, we explored the advantages and disadvantages associated with serializability in DBMS. You can check out our other blogs to enhance your knowledge:

We hope this blog helped you to understand serializability in DBMS. You can also refer to our guided paths on the Coding Ninjas Studio platform for a better understanding of the topic.

Visit our practice platform Coding Ninjas Studio to get started. Here you can practice top problems, attempt mock tests, read interview experiences, and more.You can also consider our DBMS Course to give your career an edge over others.

Happy Learning!!

Previous article
Thomas Write Rule in DBMS
Next article
States of Transaction in DBMS
Live masterclass