DEV Community

Harsh Mange
Harsh Mange

Posted on • Originally published at harshmange.hashnode.dev on

Understanding Conflict Serializability in DBMS

In database management systems, serializability is a property that ensures that the concurrent execution of transactions produces the same results as if the transactions were executed serially, one after another. Conflict serializability is a specific type of serializability that ensures that there are no conflicts between transactions during their concurrent execution.

A conflict between two transactions occurs when they access the same data item and at least one of them modifies it. The following four types of conflicts are considered in conflict serializability:

  1. Read-Write conflict (RW): A transaction reads a data item that another transaction has written to.

  2. Write-Read conflict (WR): A transaction writes to a data item that another transaction reads.

  3. Write-Write conflict (WW): Two transactions write to the same data item.

  4. Read-Read conflict (RR): Two transactions read the same data item.

In order to ensure conflict serializability, a schedule of transactions needs to be tested to see if it is conflict equivalent to some serial schedule. A schedule is conflict equivalent to a serial schedule if the two schedules produce the same result, and there are no conflicts between transactions in the schedule.

Let's consider an example to understand this concept more clearly:

Suppose we have two transactions T1 and T2, and a database with two data items X and Y. The following is a schedule of the transactions:

Schedule S1:

T1: Read(X) T2: Read(Y) T2: Write(Y) T1: Write(X)

The above schedule contains two conflicts:

  • T1 reads X while T2 writes Y.

  • T2 writes Y while T1 writes X.

Now, let's consider a serial schedule that is equivalent to S1:

Schedule S2:

T2: Read(Y) T2: Write(Y) T1: Read(X) T1: Write(X)

S2 is a conflict equivalent schedule to S1, as it produces the same result and there are no conflicts between transactions in S2. Therefore, S1 is conflict serializable.

In summary, conflict serializability ensures that the concurrent execution of transactions produces the same result as if they were executed serially, while preserving the integrity of the data in the database. It is an important concept in database management systems to ensure the correctness of the system.

Top comments (0)