Swapping of Non-Conflict Pairs

Before learning and swapping Non-Conflict pairs, you must know about conflict pairs in DBMS.

Keep in Mind: You must remember only the Non-conflict pairs are swappable. There is no possibility to swap the conflict pairs.

Why We Use Swapping?

Sometimes, a given schedule is parallel, and we try to make it serial by swapping non-conflict pairs. If a given schedule becomes serial, then this schedule is known as a conflict serializable schedule; otherwise, it will not be a conflict serializable schedule.

Method To Swap Non-Conflict Pairs

  • Find the Adjacent Non-conflict pairs.
  • Swap the non-conflict pairs.

Condition for swapping

  • Just swap the position of non-conflict pairs in the same transaction; don’t swap the operation of that transaction.

How To Swapping?

Let’s explain with an example. Consider the following schedule

Step 01:  First, find the “adjacent Non-conflict pair” from the given schedule. If it exists, then swap it as given below in the diagram

Step 02: Repeat step 1 until no adjacent non-conflict pair exists.

As we can see, the given schedule “A” (which was not serial ) is converted into the serial schedule. so it is a serial schedule.  After swapping, if the given schedule (Say “A”) becomes serial and equal to some other schedule(Say “B”), then both schedules  (“A” and “B”) will conflict with equivalent schedules.

Example 02:

In the following example, there is no adjacent non-conflict pair, so the following schedule cannot be converted into serial, so the following schedule is not serial.