Basics of a Schedule | DBMS

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello friends now in the series of videos in transactions as we have understood what are the basics of transactions then we have discussed you know the acid properties and the basic lifecycle of transaction and in last few videos we have just concentrated you know that what kind of problems may arise when multiple transactions are executed together now as a solution in this video first we'll understand what our schedules what are the rules of parallel executions and how we can ensure that when a bundle of transactions are executed together which is generally called as what schedule then how can we ensure that it will make system or it will maintain the consistency of the database which is a very important to mark question because this concepts will lead you to conflict serializability which is very popular question in gate and all other public sector exams and ask in to Marx okay okay friends now we understood what is the basic of schedule here you see I have taken example you see I have two independent transaction one is T one watches one is T two you can assume that they are working on shared data so what T one is doing T one is first reading and then updating or writing a and then working on B while T two works on the same data in B but in reverse order so T two first work on B and then works on E okay now you here you see there are two kind of methods where I call them schedule now let me first discuss what is a schedule now a schedule is a bundle of transactions executing together the entire unit is called what schedule some logics you must understand even if I say that transactions are executing together we know for computer architecture from operating system even in a multi programming system how many instructions can execute at a time or how many programs can execute at a time how many processes can be there so we know even if it is a multi programming architecture multi programming means multiple processes are there in main memory but until and unless you have a single processor at any instant of time we can execute only how many process 1 process then you may you know wonder that how it is possible even in our computer all the nowadays we have multi processing architecture but even with single processor how it is possible to run multiple process together so we know that it is okay that if we execute only one process at a time but processor is so powerful that it do frequent context switches among different processes and we get a simulation and we feel ok different processes are executing together but actually certainly it is not the case why CPU is executing one instruction at a time than some instructions of some other process and context switching between them so fastly that you feel that ok everything is going simultaneously but actually it is not so see I have taken care of that at any row only one instruction executes so if you know transaction t1 is executing transaction t2 or any other transaction cannot do anything because even with concurrency at any instance only one instruction execute because we are assuming that we are designing a system for a unit processing engine okay now you understood what is the schedule let me say these both are examples of said you'll let me and then in the later stage will understand what is the difference between them but what is a should duel a schedule is nothing but you know a set of transactions which are executing concurrently few things you must notice one first the number of instruction in independent transactions has to be there all the instructions has to be there inertia dual it means what if let me say two transactions are there the first one have you know and one instruction let me say in the second transaction let me say have and two instruction then can you tell me how many instructions will be there in a schedule the answer will be n1 plus n2 it means what that is okay that now you are executing them as a schedule as a bundle but you must take every instruction point number one point number two which is more important here you see is it an essential to run entire transactions and delgo answer is no you see here first I have executed two instructions of transaction t1 then instead of completing it I make a contact switch to what transaction t2 then two instruction of transaction t2 then back to t1 like this so we can do a number of context switch but you understand this thing can I change the order of execution of an independent transaction answer is no you see if read operation is performed for us before what right operation so I cannot change the sequential order of execution that will be preserved what Liberty you have just you can make frequent contact switches to again write a paheli perform hoon ahead open a he perform agha read B say huh years orderly nenneke write a k but here it be perform oh is Beach my context which gurkha you can execute some other processes so you understand the sequential order of the independent transaction must be preserved even though you may make you you may do a number of context switches okay now two points I have discussed first you must first take all the instructions of both or no many many transactions you have you must take instructions of every transaction point number one point number two you cannot change the sequential order of independent transactions just what can you do you can make frequent contacts which is no matter how many times you want that is okay okay now we understand this thing these are two very simple examples of how to transaction can be mix and you see it is very simple compared to this transaction where you see in the schedule what I have done first I have executed completely what t1 and then I executed what T sorry first executed I have executed what t2 and then what t1 but here if you see I have made a number of contexts such as now you are understand we already know that if only one transaction executes sat a time then acid properties are sufficient and they can ensure consistency of a database it means what if you said in this case you see I am just calling it schedule but you see I have never used the degree of concurrency because at any instance only one transaction is executing first I have completely executed what t2 and then executed what t1 so can you tell me that is there any risk of having inconsistency in this kind of a system Kakui cut receptor Cabiria harper inconsistency qey answer is no why because just for a sake of you know naming I am calling it you know dual but otherwise it is a simple transactions first one transaction executed then what other transaction is a very simple serial logic so you understand this thing this kind of a schedule is called serial schedule understanding this kind of a schedule is called serial schedule why we call it serial schedule a serial schedule is a schedule in which after executing one transaction then only you can start the other transaction or at any instance of time we can be working only on what one transaction you see it is certainly not necessary that you first executed t2 then you go to t1 you can have the Dule means what you can also could have started with what t1 and then could have come to what t2 so now you understand there are two logics possible in this particular case but yes both of them will be what serial schedule now you tell me if I schedule is serial is there exists any risk or any possibility of inconsistency answer is no why because if you are executing only one transactions at a time then there is no you know risk of having any kind of problem now it gives a very important conclusion which is what if a schedule is serial means if you have combined transactions in a serial fashion then they will ensure consistency of a database yes okay now you study this one second case here after exhibiting some transaction you go to second then you come back to first and then you come back to what second I am NOT going specifically into the cases but you understand we have already discussed four different kind of problems that if there exists concurrency and multiple transactions executed together then there's always our risk of you know inconsistency now you understand this schedule is called it non serial schedule now that one was serial and this is what non serial now when can you say our schedule is non serial if before completing one transaction you switch context switch to some other transaction then that will be you know cases of simply what non serial schedules so now you understand if a schedule is non serial am i saying that it will always take the system to inconsistency answer is no you understand this thing even if you are non serial it is not necessary that you will take a system into what inconsistency but of course there is a potential risk that yes this kind of a scenario sometimes may take system into what inconsistent state now you tell me we have two different methods two different logics one is serial one is non serial what is the advantage of serial it always guarantee systems consistency what is it disadvantage of a serial there is no concurrency you are only execute one transaction at a time second you come non single method in a non serial method what is the advantage certainly you have what concurrency is resource utilization waiting them everything will be less but what will will disadvantage there will be for sure a potential risk that the system may go into what inconsistent state now what we do in conflicts realisability use Eliza built in these logics we try to study that what kind of non serial schedules may be safe what kind of non zero schedules may be safe so that we can work on them and still we guarantee that the system is in what consistent state so now that is an entire scenario do you understand this thing when you bundle multiple transactions together you go you have you could have what serial you could have what non serial schedule let me discuss one more one more question some time they may ask they may ask you if you have you know multiple transactions like t1 t2 up till up till let me say t1 T n transactions executing together how many different serial schedules are possible so you understand as I've told there's nothing like a fixed order that you must first execute t1 then you come to what t2 now if you have n choices then for first transaction how many choices you have n because from t1 to TN AB just coach a house could choose car sector you can choose whatever transaction you want but then the second choice one transaction will be gone so Harman will be remaining so answer will be what n minus 1 and I think then you understand the sequence and the next choice will be what n minus 2 up till up till up till you go to what 1 so answer is what n factorial but it's a very easy one mark very popular question so if you have n transactions then how many different serial schedules are possible answer is what and factorial differential schedules are possible but here if you study in this case will it be that easy now you understand because here how many times you are doing this context switching it also depends on the number of instructions you have now you understand let me say if T 1 T 2 up till up till let me say T n they contain suppose N 1 n 2 up till up till n and instructions individually let me say so first transaction t1 have and one instructions second t2 have n 2 similarly last on the chin T and have word and n instructions so how many total transactions or total instructions will be there so for short that will be what n 1 plus what n 2 up till up till what and an instruction and let me say n factorial so what will happen there will be you know every possible order of all the transactions of all instructions of all transactions but that is actually wrong why you understood you understand this thing because this that total case will cover all those cases where you may also have you know permutation or combinations in what t1 only so you may also taking against where W a or write a is executing before what reading which is certainly not allowed so if you remember you know the basic mathematics to what should I do let me divide them by independent factorials so I divided them N 1 factorial into n fact factorial into what n n factorial so what will happen it will eliminate all those cases where I am taking different combinations of you know instructions of a particular transaction now that inequality will give you what total number of schedules possible if you want to compute only non serial schedule you have already computed what serial schedule so in total schedules you can - what non-si the total message you can - what serial schedule so now this inequality in total will give will give you what total number of non serial schedule is possible so these are some time you know simple questions they may ask so in this video we have understood what our schedules and what is non serial what is serial schedules and we understood as a concluding argument that we always you know go for what non serial schedule we should always go because actually they are the one who provides concurrency but there is a risk of going into what inconsistent state so in the next video I will discuss the basic concept of conflict serializability where we understood that what kind of a non serial schedules can be allowed with our you know with a confidence with the guarantee that they will for sure not take my system in toward inconsistent state thank you
Info
Channel: KNOWLEDGE GATE
Views: 182,947
Rating: 4.8777394 out of 5
Keywords: dbms, database management system, nptel, transaction in dbms, schedule in dbms, serial, non serial, computer science, computer science engineering, computer science lectures, computer science engineering lectures, gate, gate exam, gate exam preparation, gate computer science, gate computer science lectures, gate lectures by ravindrababu ravula, net computer science, dbms tutorial, dbms lecture, dbms gate lectures, database management system gate lectures
Id: q6ISl9YNxoQ
Channel Id: undefined
Length: 14min 22sec (862 seconds)
Published: Wed Nov 23 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.