Programs

Serializability in DBMS: Advantages, Types & Examples

Introduction to serializability in DBMS

The database is one of the main pillars of every modern application. It not only facilitates high performance but also enables a reliable storage solution for your applications. The database design can be affected by multiple factors. One such among them is serializability. 

This brings us to the question what is serializability in DBMS?

Simply put, it can be defined as a property of a system that highlights how multiple processes can operate on shared data. The results generated by the system must be in sync with the operation performed by the system for it to be called system serializable. 

Advantages of using serializability in DBMS

The benefits of enabling serializability in DBMS are many. Mentioned below are a few of the same. 

  • It leaves little to no room for any kind of data inconsistencies or anomalies that might arise when multiple transactions are trying to access the same data.
  • It facilitates consistency and significantly improves the reliability of the database.
  • It prevents the overlapping of multiple transaction operations.
  • It ensures optimum privacy, security and data accuracy. 

Check out our free technology courses to get an edge over the competition.

Basic concepts of transaction in DBMS

Before going into the details of the types of serializability in DBMS, let’s start with the basics first. 

Simply put, a transaction is a group of tasks. One single task is the minimum processing unit, meaning it cannot be divided further. However, it consists of multiple low-level tasks and must contain ACID properties to ensure the accuracy and integrity of the database. 

So what are ACID properties? 

It refers to Atomicity, Consistency, Isolation and Durability.

 

  • Atomicity denotes that every transaction process must be dealt with as a single atomic unit. In this manner, either every process is completed or none. It prevents any operation from being partially completed.
  • Consistency states that the consistency of the database must be maintained during the initial state of the transaction process and after. There must not be any kind of adverse effect on the database after the transaction has been executed. 
  • Isolation denotes that regardless of the number of transactions in a database system, each must operate as a single process. This prevents any kind of inconsistencies or overlapping of one transaction over another. 
  • Durability means that the database must hold all the latest updates, even when the system reboots or fails. 

Check Out upGrad’s Software Development Courses to upskill yourself.

What is concurrent execution in DBMS?

Concurrent execution can be defined as the ability of varied users to access and use the same database simultaneously. There might be scenarios in a multi-user system where different users might have to perform different tasks using the same database. This is where concurrent execution comes into play. 

However, when this happens, the chances of one operation interfering drastically increase. To prevent such an occurrence, it is always advisable to perform concurrent execution in an interleaved manner. This also ensures the overall consistency of the database. 

Get to learn more about the same with upGrad’s Full Stack Development Bootcamp. From professional certifications to 100+ hours of learning, you can experience the true essence of learning with real-life industry projects. 

Types of anomalies in concurrent execution

Let’s look at the potential anomalies faced in concurrent execution based on the kinds of operations or the order in which they are performed. 

  • Dirty Read- One of the most common phenomena in concurrent execution is dirty read. It happens when one transaction reads data already modified by another transaction. It leads to a breach of transaction isolation.
  • Lost Update – Another common challenge of concurrent execution is lost update, wherein two different transactions read and modify the same object interdependently. This means that the modification committed last by one transaction overwrites the previous one. It ultimately results in a loss of significant updates. 
  • Non-repeatable Read – It occurs when the same object is being read twice between a transaction. It results in the read operation being non-readable since the second read will generate different values than the first. 

Please note that these three are just a few of the many anomalies that might occur in concurrent execution. Other similar examples might include Phantom Read and Incorrect Summary Problems.

Explore Our Software Development Free Courses

What is conflict serializability in DBMS?

Conflict serializability is a characteristic of a schedule that guarantees that it is equivalent to a serial schedule. In other words, it must be able to change itself to a serial schedule even after switching its non-conflicting processes. 

Conflicting operations typically occur when three conditions are met. They are

  • When two operations belong to differing transactions
  • When both of them use similar data items.
  • When one out of two operations is a write operation. 

Check out the MS in Computer Science program offered by Liverpool John Moores University to further strengthen your understanding of conflict serializability in DBMS. Just-in-time interviews, an AI-powered profile builder, and an exclusive job opportunities portal are some of the many benefits provided by upGrad through this course. 

Comparison between conflict serializability and view serializability

Here is a detailed comparison between conflict serializability in DBMS and view serializability in DBMS

Conflict Serializability View Serializability
Two schedules can be called conflict equivalent when the conflicting operations in both are carried out in the same order. View serializability focuses on the logical effect of transactions instead of the order of operations. This means for two schedules to be considered view equivalent, the update operations, initial read, and final write must be the same. 
Conflict serializability may or may not occur when a schedule is view serializable. A view serializable schedule is also considered to be a conflict serializable schedule. 
It is quite easy to achieve by simply reordering the operations of the two transactions. It can be quite hard to achieve since both transactions need to be able to perform similar actions in an identical manner. 

 

View serializability in DBMS: Definition and examples.

View serializability in DBMS can be defined as a concept used to determine if a schedule is equivalent to a serial schedule- only then can it be called a view serializable schedule. 

To help you better understand the same, here is a small example. 

Let’s say that S1 and S2 are two schedules. A few conditions must be met for both to be view equivalent. These may include

  • Initial Read – The initial read of every data item in transactions must be in sync with both schedules. This means that in S1, if a transaction (T1) reads the data item (X) before the transaction (T2), then the same must occur in S2 as well. 
  • Final Write – The second condition is that the final write operations must match each data item. For example, in S1, if T1 performed the last write operation, then the same must be performed by T1 in S2 as well. 
  • Update Read – Lastly, if in S1, transaction T1 is reading a data item uploaded by T2, then in S2, T1 should also be able to read the value on the same data item.

Explore our Popular Software Engineering Courses

Understanding precedence graph in DBMS

A precedence graph in DBMS is a popular tool for checking conflict serializability. It is also sometimes referred to as the conflict graph or serialization graph. It typically consists of a set of nodes signified by V and a set of directed edges (E). 

The steps involved in a precedence graph goes as follows,

  • For every transaction (T), assign a node or vertex in the graph.
  • Put an edge from Ti to Tj for every conflicting pair.
  • The schedule can only be considered conflict serializable in the presence of a cycle in the graph. If not, then the schedule is not conflict serializable. 

Example of serializable and non-serializable schedule in DBMS

Here is an example of a serializable schedule.

Transaction T1 Transaction T2
R (E)
W (E)
R (F)
W (F)
commit
R (E)
W (F)
commit

 

In this table, there are two transactions, namely T1 and T2, that perform some operations. E and F refer to data items. Thus R (E) signifies reading E, whereas W signifies writing or updating F. Here, T1 is followed by T2, i.e. T1 > T2, which denotes a serial schedule. 

 

Transaction T1 Transaction T2
R1 (E)
W1 (E)
R2 (E)
W2 (E)
R1 (F)
W1 (F)
R2 (F)
W2 (F)

 

Contrary to the previous one, here, both the transactions, namely T1 and T2, are executing concurrently. The operations are interleaved. Thus, the schedule is non-serialized.

How serializability improves database performance

Serializability is an integral part of DMBS as it ensures data integrity. Without the same, your database might contain inconsistent data, which would, in turn, lead to faulty results in your front-end application. 

Serializability helps to schedule transactions in the order in which they are executed. A small example to help you understand include-

Let’s say a user tries to send a transaction to the database to read and then write to a table. Another user is also trying to send the same set of queries. This is where serializability comes into play. It tactfully ensures that the first transaction is properly processed, followed by the second transaction. In this manner, it not only improves the database performance but also ensures that the data contains a value that is in sync with the business logic. 

In-Demand Software Development Skills

Techniques for maintaining serializability in DBMS

Let’s take a look at a few techniques used for maintaining serializability in DBMs

  • Lock-Based Concurrency Control
  • Optimistic Concurrency Control
  • Timestamp-Based Concurrency Control
  • Conflict Serializability Analysis

Conclusion

With this, we come to an end of serialization in DBMS. While exploring the various types of serializability in DBMS, we learnt that each has its own advantages and disadvantages. The best way to avoid anomalies and discrepancies to become a part of the process is to leverage the right one aligned with the design, intent and architecture. 

There are also multiple online courses that you can check out to strengthen your knowledge of serializability in DBMS. One such includes upGrad’s Post Graduate Program in Software Development from IIIT-B. It mainly focuses on full-stack development and trains you in all the necessary skills to emerge as a successful leader. 

What’s more? It also comes with numerous advantages, such as the No Cost EMI option, personalised industry sessions, and an exclusive job opportunities portal, transforming your career to become future-proof! 

What are the different types of serializability?

There are mainly three types of serializability in DBMS. They are- Result Equivalent Schedule, View Equivalent Schedule, and Conflict Equivalent Schedule. Each has its own advantages and disadvantages.

How can you implement conflict serializability in DBMS?

Multiple concurrency control techniques are used to achieve conflict serializability in DBMS. A few of the same include timestamp ordering and locking.

What is the importance of serializability in DBMS?

When more than one transaction tries to access the same data, it is very common for one operation to interfere with the other. Serializability prevents this from happening and leaves little to no room for other anomalies or disruptions.

Want to share this article?

Leave a comment

Your email address will not be published. Required fields are marked *

Our Popular Software Engineering Courses

Get Free Consultation

Leave a comment

Your email address will not be published. Required fields are marked *

×
Get Free career counselling from upGrad experts!
Book a session with an industry professional today!
No Thanks
Let's do it
Get Free career counselling from upGrad experts!
Book a Session with an industry professional today!
Let's do it
No Thanks