Schedules in DBMS-
Serial Schedules-
In serial schedules,
• All the transactions execute serially one after the other.
• When one transaction executes, no other transaction is allowed to execute.
Characteristics-
Serial schedules are always-
• Consistent
• Recoverable
• Cascadeless
• Strict
Example-01:
In this schedule,
• There are two transactions T1 and T2 executing serially one after the other.
• Transaction T1 executes first.
• After T1 completes its execution, transaction T2 executes.
• So, this schedule is an example of a Serial Schedule.
Example-02:
In this schedule,
• There are two transactions T1 and T2 executing serially one after the other.
• Transaction T2 executes first.
• After T2 completes its execution, transaction T1 executes.
• So, this schedule is an example of a Serial Schedule.
Non-Serial Schedules-
In non-serial schedules,
• Multiple transactions execute concurrently.
• Operations of all the transactions are inter-leaved or mixed with each other.
Characteristics-
Non-serial schedules are NOT always-
• Consistent
• Recoverable
• Cascadeless
• Strict
Example-01:
In this schedule,
• There are two transactions T1 and T2 executing concurrently.
• The operations of T1 and T2 are interleaved.
• So, this schedule is an example of a Non-Serial Schedule.
Example-02:
In this schedule,
• There are two transactions T1 and T2 executing concurrently.
• The operations of T1 and T2 are interleaved.
• So, this schedule is an example of a Non-Serial Schedule.
Serializability in DBMS-
• Some non-serial schedules may lead to inconsistency of the database.
• Serializability is a concept that helps to identify which non-serial schedules are correct and will
maintain the consistency of the database.
Serializable Schedules-
If a given non-serial schedule of ‘n’ transactions is equivalent to some serial schedule of ‘n’ transactions,
then it is called as a serializable schedule.
Characteristics-
Serializable schedules behave exactly same as serial schedules.
Thus, serializable schedules are always-
• Consistent
• Recoverable
• Casacadeless
• Strict
Serial Schedules Vs Serializable Schedules-
Serial Schedules Serializable Schedules
No concurrency is allowed. Concurrency is allowed.
Thus, all the transactions necessarily execute Thus, multiple transactions can execute
serially one after the other. concurrently.
Serial schedules lead to less resource utilization Serializable schedules improve both resource
and CPU throughput. utilization and CPU throughput.
Serial Schedules are less efficient as compared to Serializable Schedules are always better than
serializable schedules. serial schedules.
(due to above reason) (due to above reason)
Types of Serializability-
Serializability is mainly of two types-
1. Conflict Serializability
2. View Serializability
Conflict Serializability-
If a given non-serial schedule can be converted into a serial schedule by swapping its non-conflicting
operations, then it is called as a conflict serializable schedule.
Conflicting Operations-
Two operations are called as conflicting operations if all the following conditions hold true for them-
• Both the operations belong to different transactions
• Both the operations are on the same data item
• At least one of the two operations is a write operation
Example-
Consider the following schedule-
In this schedule,
• W1 (A) and R2 (A) are called as conflicting operations.
• This is because all the above conditions hold true for them.
Checking Whether a Schedule is Conflict Serializable or Not-
Follow the following steps to check whether a given non-serial schedule is conflict serializable or not-
Step-01:
Find and list all the conflicting operations.
Step-02:
Start creating a precedence graph by drawing one node for each transaction.
Step-03:
• Draw an edge for each conflict pair such that if Xi (V) and Yj (V) forms a conflict pair then
draw an edge from Ti to Tj.
• This ensures that Ti gets executed before Tj.
Step-04:
• Check if there is any cycle formed in the graph.
• If there is no cycle found, then the schedule is conflict serializable otherwise not.
Check whether the given schedule S is conflict serializable and recoverable or not-
Solution-
Step-01:
List all the conflicting operations and determine the dependency between the transactions-
• R2(X) , W3(X) (T2 → T3)
• R2(X) , W1(X) (T2 → T1)
• W3(X) , W1(X) (T3 → T1)
• W3(X) , R4(X) (T3 → T4)
• W1(X) , R4(X) (T1 → T4)
• W2(Y) , R4(Y) (T2 → T4)
Step-02:
Draw the precedence graph-
• Clearly, there exists no cycle in the precedence graph.
• Therefore, the given schedule S is conflict serializable.