DBMS Schedule
A schedule is a process of combining the multiple transactions into one and executing the operations of these transactions in a predefined order. A schedule can have multiple transactions in it, each transaction comprising of several tasks or operations or instructions.
A schedule can also be defined as “a sequence of operations of multiple transactions that appears for execution”. Or we can say that when several transactions are executed concurrently in the database, then the order of execution of these transactions is known as a schedule. A specific sequence of operations of a set of instructions is called a schedule.
Schedule Example
Schedule 1:
Time | Transaction T1 | Transaction T2 |
t1 | Read(A) | |
t2 | A=A+50 | |
t3 | Write(A) | |
t4 | Read(A) | |
t5 | A+A+100 | |
t6 | Write(A) | |
t7 | Read(B) | |
t8 | B=B+100 | |
t9 | Write(B) | |
t10 | Read(B) | |
t11 | B=B+50 | |
t12 | Write(B) |
Types of Schedule
Schedule is of two types:
- Serial schedule
- Non-serial schedule
Serial Schedule
The serial schedule is a type of schedule in which the transactions are executed one after other without interleaving. It is a schedule in which multiple transactions are organized in such a way that one transaction is executed first. When the operations of first transaction complete, then next transaction is executed.
In a serial schedule, when one transaction executes its operation, then no other transaction is allowed to execute its operations.
For example:
Suppose
a schedule S with two transactions T1 and T2. If all the instructions of T1 are
executed before T2 or all the instructions of T2 are executed before T1, then S
is said to be a serial schedule.
Below tables shows the example of a serial schedule, in which the operations of first transaction are executed first before starting another transactionT2:
Time | Transaction T1 | Transaction T2 |
t1 | Read(A) | |
t2 | A=A+50 | |
t3 | Write(A) | |
t4 | Read(B) | |
t5 | B=B+100 | |
t6 | Write(B) | |
t7 | Read(A) | |
t8 | A+A+100 | |
t9 | Write(A) | |
t10 | Read(B) | |
t11 | B=B+50 | |
t12 | Write(B) |
Non-Serial Schedule
The non-serial schedule is a type of schedule where the operations of multiple transactions are interleaved. Unlike the serial schedule, this schedule proceeds without waiting for the execution of the previous transaction to complete. This schedule may give rise to the problem of concurrency. In a non-serial schedule multiple transactions are executed concurrently.
For example:
Time | Transaction T1 | Transaction T2 |
t1 | Read(A) | |
t2 | Read(A) | |
t3 | A=A+50 | |
t4 | A+A+100 | |
t5 | Write(A) | |
t6 | Write(A) |
In this schedule S, there aretwo transaction T1 and T2. If T1 and T2 transactions are executed concurrently, and the operations of T1 and T2 are interleaved. So, this schedule is an example of a non-serial schedule.