Schedules in DBMS-Tutorial

Schedules

In a database system, we can have number of transaction processing. Related transactions will be processed one after another. There are some transactions processes in parallel. Some of the transactions can be grouped together.
schedule is a process of grouping the transactions into one and executing them in a predefined order. A schedule is required in a database because when some transactions execute in parallel, they may affect the result of the transaction – means if one transaction is updating the values which the other transaction is accessing, then the order of these two transactions will change the result of second transaction. Hence a schedule is created to execute the transactions. A schedule is calledserial schedule, if the transactions in the schedule are defined to execute one after the other.
Even when we are scheduling the transactions, we can have two transactions in parallel, if they are independent. But if they are dependent by any chance, then the results will change. For example, say one transaction is updating the marks of a student in one subject; meanwhile another transaction is calculating the total marks of a same student. If the second transaction is executed after first transaction is complete, then both the transaction will be correct. But what if second transaction runs first? It will have wrong total mark.


This type of incorrect processing of transaction needs to be handled in the system. Parallel execution of transaction is allowed in the database only if there is any equivalence relation among the transactions. There are three types of equivalence relation among the transactions – Result, view and Conflict Equivalence.
Result Equivalence: - If the two transactions generate same result after their execution then it is called as result equivalence. For example, one transaction is updating the marks of Student X and the other transaction is to insert a new student. Here both the transactions are totally independent and their order of execution does not matter.  Whichever order they are executed; the result is the same. Hence it is called result equivalence transactions.
View Equivalence: -Two schedules are said to be view equivalence, if the transaction in one schedule is same as the one in other. That means, both the transactions in two schedules perform same tasks. For example, say schedule1 has transaction to insert new students into STUDENT table and second schedule has the transaction to maintain the old student records in a new table called OLD_STUDENT. In both the schedules student details are inserted, but different tables (it does not matter if it is same table). Such schedules are called as view equivalence schedule.
Conflict Equivalence: - In this case both schedules will have different set of transactions, but they would be accessing same data and one of the schedules will be inserting/updating the records. In this equivalence, both the schedules will have conflicting set of transactions. Above example of updating the marks of one student by one transaction and calculating the total marks at the same time is a conflicting equivalence.
In all these cases if the transaction is serialized, then the issues can be resolved.



            

  Concurrency Control

Previous Post
Next Post