2080 1

BIT202 · 2080 · 10 marks

Define serial, non-serial and serializable schedules with example. How can you test serializability in a schedule? Explain with an example.

Define serial, non-serial and serializable schedules with example. How can you test serializability in a schedule? Explain with an example.[10]

Database Management SystemChapter 7: Transaction ManagementSerial and non-serial schedules

Quick answer

A serial schedule is one in which transactions are executed one after another, without any interleaving of operations. One transaction must complete entirely before the next one begins.

Serial, Non-Serial, and Serializable Schedules

1. Serial Schedule

Properties:

  • No concurrency
  • Always consistent (correct by definition)
  • Poor performance due to no overlap

Example:

StepT1T2
1Read(A)
2Write(A)
3Read(B)
4Write(B)
5Read(A)
6Write(A)
7Read(B)
8Write(B)

Here T1 executes completely before T2 starts. This is a serial schedule: T1 → T2.


2. Non-Serial Schedule

A non-serial schedule is one in which operations of multiple transactions are interleaved with each other. Transactions execute concurrently.

Properties:

  • Allows concurrency and better throughput
  • May or may not produce consistent results
  • Not all non-serial schedules are correct

Example:

StepT1T2
1Read(A)
2Read(A)
3Write(A)
4Write(A)
5Read(B)
6Write(B)
7Read(B)
8Write(B)

Here operations of T1 and T2 are interleaved. This is a non-serial schedule.


3. Serializable Schedule

A serializable schedule is a non-serial schedule that produces the same result as some serial schedule of the same transactions. It is the standard criterion for correctness of concurrent execution.

A non-serial schedule S is serializable if it is equivalent to some serial schedule.

Types of Serializability:

  • Conflict Serializability (most commonly tested)
  • View Serializability

4. Testing Serializability: Precedence Graph (Conflict Graph) Method

Concept of Conflicting Operations

Two operations conflict if:

  1. They belong to different transactions
  2. They access the same data item
  3. At least one of them is a Write
Operation PairConflict?
Read(X) - Read(X)No
Read(X) - Write(X)Yes
Write(X) - Read(X)Yes
Write(X) - Write(X)Yes

Steps to Test Conflict Serializability

Step 1: Identify all pairs of conflicting operations between different transactions.

Step 2: Build a Precedence Graph (Serialization Graph):

  • One node for each transaction
  • Draw a directed edge from Ti → Tj if an operation of Ti conflicts with an operation of Tj, and Ti's operation appears before Tj's operation in the schedule

Step 3: Check for cycles in the graph:

  • No cycle → Schedule is conflict serializable
  • Cycle exists → Schedule is NOT conflict serializable

Worked Example

Consider the following schedule S with transactions T1, T2, T3:

StepT1T2T3
1Read(X)
2Read(X)
3Write(X)
4Read(X)
5Read(Y)
6Write(Y)
7Write(Y)
8Write(X)

Step 1: Identify Conflicting Pairs

ConflictOperationsEdge
T2: Write(X) before T1: Read(X)Both on X, Write involvedT2 → T1
T1: Read(X) at step 1 before T2: Write(X) at step 3Both on X, Write involvedT1 → T2
T2: Write(Y) before T3: Write(Y)Both on Y, Write involvedT2 → T3
T3: Read(Y) before T2: Write(Y)Both on Y, Write involvedT3 → T2

Step 2: Draw Precedence Graph

T1 ---------> T2
 ^             |
 |             v
 +---- T2    T3 <----> T2

More precisely:

  • T1 → T2 (T1 reads X before T2 writes X)
  • T2 → T1 (T2 writes X before T1 reads X at step 4)
  • T2 → T3 (T2 writes Y before T3 writes Y)
  • T3 → T2 (T3 reads Y before T2 writes Y)

Step 3: Check for Cycles

  • T1 → T2 → T1 forms a cycle
  • T2 → T3 → T2 forms a cycle

Conclusion: The schedule contains cycles in the precedence graph, therefore it is NOT conflict serializable.


Example of a Serializable Schedule

StepT1T2
1Read(A)
2Write(A)
3Read(A)
4Write(A)
5Read(B)
6Write(B)

**Conflicting

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.