Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
57 views
36 pages
Feb 22, Doc 1
Uploaded by
Ankush Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save Feb 22, Doc 1 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
57 views
36 pages
Feb 22, Doc 1
Uploaded by
Ankush Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save Feb 22, Doc 1 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save Feb 22, Doc 1 For Later
You are on page 1
/ 36
Search
Fullscreen
Normalization is part of the Successful database design, without normalization, database systems may be inaccurate, slow and inefficient and they might not produce the data we expect. When we normalize the database, we have four goals : 1. Arranging data into lo, the whole. 2. Minimizing the amount of duplicate data, 3. Organizing the data such that, when you one place. sical groupings such that each group describes a small part of called redundancy, stored in a database, modify it, you make the changes only in 4. Building a database in which you can access and manipulate the data quickly and efficiently without compromising the integrity of the data in storage. 155Database Management S} f reducing data redundancy in a relational da rocets Of Fiaty, normalization is a refinement process inte ee ee fter identifying the data objects of the proposed Matabontsbase ‘and columns within each table. The finden data should not be stored in multiple place: egal Sipbliniet op tabled mehctilly (tcReaaman ines the tables required ‘alization is “The same in the process, however, ges of normalization are + from certain add, edit and delete anomalies. restructure the database as new kinds of data are introduced tive to users, including different users making The main advantat « It frees the database «+ Itreduces the need to » Itmakes the database more informal different queries. « jt avoids biasing the database design in favour of certain queries at the expense of others, + It allows the operations needed otherwise have to be. Designing a normalized database structure is the first step when building a database. ‘Taking time to properly design the database is the most important step in developing database-oriented solutions. Normalization is @ simple, common sense process that leads cotenible, efficient and maintainable database structures: eee 5.2, FUNCTIONAL DEPENDENCY (UPTU, 2006) (Imp,) 'd by XY, between two sets of) attributes Xand Y that are toy the possible tuples that can from a relation, state r two tuples t, and f, in that have for data access to be simpler than they would ‘A functional dependency, denotes subsets of R specifies a constraint or R. The constraint is that, for any 1X] = 4141. We must also have 4111 = of¥)- ‘this means that the values of the’ Y component of a tuple in r depends on, or are values of the X component determined, by the values of the. _X component; or alternatively, the ve of a tuple uniquely (or func! ‘ne Y component. We also say tionally) determine the value of t] that there is a functional dependency from X to ¥ oF that Yis functionally dependent on x, The abbreviation for Yis functionally dependent is FD or f.d. The set of attributes X is called the left-hand side of the FD, and Yis called the right-hand side. ‘An attribute in a relational model table is said to be functionally dependent on another attribute in the table if it can take one value for @ given value of the attribute upon which it is functionally dpendent. play a key role in Functional dependencies bad database designs. A functional dependency i of the notion of key- Itis denoted by >; A> B differentiating good database designs from sa type of constraint that is a generalization For example: Consider the relation schema —————————___———__ EMP_PROJ [ssn | PNUMBER [HOURS] ENAME | PNAME [_PLocarion FD, ae FD, FD, ; From the semantics of the attributes, we know that the following functional dependencies should hold : (a) SSN > ENAME (6) PNUMBER ~ (PNAME, PLOCATION} (o {SSN, PNUMBER} > HOURS, specify that (a) the value of an employee's social security ‘These functional dependencies number (SSN), uniquely determines the employeename (ENAME), (b) the value of a projects's vember (PNUMBER) uniquely determines the project name (PNAME) and location .d PNUMBER values uniquely determines {PLOCATION) and (¢) a combination of SSN an cre number of hours the employee works on the Project Pet Week (HOURS). Alternatively, we say that ENAME is functionally determined by (or functionally dependent on) SSN. 'A FD. is a property of the relation schema (intension) R, not of a particular legal relation state (Extension) r of R, Hence, and FD, cannot be inferred automatically from a given relation extension r but must be defined explicitly by someone who knows the ccmantics of the attributes of R, The above mentioned figure introduces a diagramatic Sefation for displaying FDs: Each FD is displayed as a horizontal line, The left hand-side attributes of the FD are connected by vertical lines to the line representing the FD, while the right hand side attributes are connected by arrows pointing towards the attributes. 5.2.1. Closure of a Set of Functional Dependencies (uPrU, 2003) “The schema designer specifies the F.D. that the semantically obvious, usually, however, jumerous other F-D. holdin al legal relation instances that satisfy the dependencies in Fr whose other dependencies can be inferred or deduced from the FDs in F. For feab-life ceenple, it is practically impossible to specify all possible functional dependencies that Grey hold. The set of all such dependencies is called the closure of Fand is denoted by /*. ‘ror example : Suppose that we specify the following F of obvious FD on the relation schema. F= {SSN > (ENAME, BDATE, ADDRESS, DNUMBER), DNUMBER + DNAME, DMGRSSN} We can infer the following additional F.D. from F: SSN = (DNAME, DMGRSSN}, SSN = SSN, DNUMBER = DNAME An FD X-> Yis inferred from a set of dependencies F specified on Rif X> Yholds im that is legal extension of R ; ie., whenever r satisfies all the Yalso holds in r, The closure F* of Fis the set of all F.D. that can IR®) are well-known as Inference every relation state 1, dependencies in F, X> be inferred from F. The following six Inference Rules (IR, to I rules for functional dependencies :then & >, holds, (PTY 2099 aset of attributes, then yq, > by sa set of attributes and poe® IR, : Reflexivity Rule * If ai js holds and 718 Ifa Pr holds, then @ > ¥ holds. IR,: Augmentation Rule holds. - IR, : Transitivity Rule + Ifa B holds ans IR, : Union Rule : If >? holds and & “hy IR, : Decomposition Rule: Ifa>B hol A IR, : Pseudotransitivity Rule: Ifa 7B ho - «pat Axio! ‘The rules IR;, IR, and IR, are ale RA. honour of the person who first propose? 1 ; a oe ‘The Reflexivity rule (IR,) states that 4 ae a att endencied beeen OF any of ; Ve ems a s its subsets, which is obvious. BH, Sepa Vie trivel XE othe Ue, iL g the same set of attributes * 7 itig oth such dependencies are called trivi Se aadic ner valid dependency. Aceon nontrivial. The augmentation Rule (IR,) Svs nee fa dependency results in anothe “ i es are transitive. The union rule (IR,) aj ing i lows the left and right handsides 0 oe to Transitivity rule (IR,); functional dependene™ > ; 1p combine alset of dependencies > A137" Ay eX aon nt single {A,, Ag) «11» Ap}: The decomposition rule (IR) says that we cae ributes from id : applying this rule repeatedly we can decompose the p® jes (XK Ay, X79 Ay XA; le RD right-hand side of a dependency X-— {A,, Ay, «. 4,} into the set of dependenci ed from the definition of 5 proved iré F.D. either by Each of preceding inference rules can be direct proof or by contradiction. poo holds,then & > fy holds. then a 3B holds, and «+ holds, jas and vB -* 5 holds,then 1 8 hojg, ms” or Armstrong's Axiom, In EXAMPLE 5.1. 1 Given a set of F.D- A> B, ABCD Eand EF > G Is ACDF > G, implied by the set of given FD’s ? A> B, ABCD>E ACD = E (by Pseudotransitivity Rule) ACDF > EF (by Augmentation Rule) ACDF 4 G (by Transitivity Rule) Hence ACDF > G First three rules are known as Armstron; i ivi : axions. The Reflexivity Rul a a set of attributes always determines itself or any of its subsets, which eae ag 4 such type of obvious dependencies is called as trivial dependencies. S dependency X—> Yis trivial, if Xc Y; ee Otherwise it is non-trivial. Solution: Given Implies Again EXAMPLE 5.2. Given two sets F, and F, of FDs for a relation. F,:A> B AB>C,D>AC DOE F,:A— BC, D> AE Are the two sets equivalent ? Solution: From F, , D> AC a7 DA (by Decomposition Rule) Doc Also given that DE So DAE (by Union Rule) which is a FD of set Fy. Again A> Band AB C Imply A C (by Pseudotransitivity Rule) A BC (by Union Rule) which is FD of set Fy. Hence F, and F, are equivalent. 5.2.2. To Find Closure A BG, E> CF, B> Eand C> EF EXAMPLE 5.3. Compute the closure X* of the set of attributes (4, 3 under the given set of Fs, Initialize X= {A,B xt) = {A, B,Q Xx) = {A, B, C, B X08) = {A, B,C EA x) ={A, B,C, BP x0) = x) ¢ of the given F.D. over (4, 5) is {AB ‘= (4, B,C BA Hence closur’ A> B, BC>D,C>E, CD>F. EXAMPLE 5.4. Find closure of (A, Q* X) = (4, O XO) = (4, BO B68 {A,B,C E, Dt (A, B, C, D, E, F} ={(4,B,6D,E7 x8 = xO) Hence (A, 0° = (4B, CDE EXAMPLE 5.5. A B, BC DE, AEF > G. Find closure of (A, O) xX) = {AG Xi) = {A, B, O th edais} S Database Management System X@) = (A, B, CF, B X0) = {A, B,C, D, B Xx) = xe) Hence (A, Q* = {A, B, CD, B 5.2.3. To Find Super Key, Candidate Key and Irreducible EXAMPLE 5.6. ABCD E Super Key = {ABCDG)} AB~> G BoF Cu Super Key = (ABCDO} aol GoH = ABCDGJ (:. C>) = ABCDG =ABCD (-. AB? Q) Because neither of (ABCD) is functionally determine by any F.D. So (ABCD) is an irreducible set. Hence candidate key = {A, B, C, Di EXAMPLE 5.7. AB Super Key = (ABCEF, BC>D BC>E AEF G = ABCEF (-. C> E) B3G =ABCF =ACF . (--A>B) Candidate key = {4,6 EXAMPLE 5.8. AB BCD Super key = {ABCDE} CoE Doc E— F=ABCDE (:.C> 4) Since it replace only one attributes. =ABCDE (-.B— CD) =(4B,B (--A>B) = {A, B = (AB) = Candidate key or irreducible set. EXAMPLE 5.9. AB>C CoANormaiizat, a roe Ace 161 28), CSui Per key = (ABCD Ey BE DEF PACA AECD (cop sp CEs p ~E,D3A CEA CFB = (ABQ |. CFoap (ABQ (-. BC+ Dy DAE AD in (e Desir (. ABs 9 + Candidate key (4, EXAMPLE 5.10. A BC, BOE CD EF = ABCD (-. A BQ) =AD Super key = (ABCD, = Candidate key or irreducible set. ABS C A DE Bor F> GH DoW =(ABDFR) ABD (-.B> ABD EXAMPLE 5.11. ‘Super key = {ABDF) = Candidate key or irreducible set. Canonical Cover Consider the following set F of functional dependencies on shemea (A, B, Q: ABC, B>C, A+B, AB>C Let us compute the canonical cover for F. + There are two F.D. with the same set of attributes on the left side of the arrow : A+BC,A3B We combine these F.D. into A > BC. + Ais extraneous in AB C, because F logically implies (F={AB — C}) U {B > C}. This assertion is true because B > C is already in our set of F-D. * Cis extraneous in A BC, since A > BC is logically implied by A> Band B> C. Thus, our canonical cover is A >B BOCa Database Management System IPTU, 2006) 5.3. LOSSLESS/LOSSY JOIN peEcomposiTioN P ca pas 2 a i ncie: . Let Rbe a relation schema, and let Fbe a set of functions! See ath ae ae ae R, form a decomposition of R. Thus decomposition ee i on ion o at least one of the following functional dependencie . RRR e RORFR . RAR OR R, a f : se. Bi ropeiata SODETRCY of either R, oF Ro the composition of R oe in other words, if Ry 7 Rp fo of decomposition of arelation into multiple ele re complicated. ition. For the gen for lossless join dec position i f all cons omposition is m0 is clearly a SU) traints are func’ lossless-join decompos' parts of once, the test While the test for binary decom) join, it is a necessary condition only i sider scheme S=(VW%YD Z>V woy XY 9Z vo Wx S,=(VW,%) 5-7 S39 S-) V—> Wx Since (V, W, X) are present in S;- Hence it is lossless-join decomposition. ficient condition for lossless tional dependencies. For example: Con (a S, = (V, WX) (KF ; 8,95 - (4) Since there is no f.d. Hence it is lossy-join decomposition. Same example can be done by matrix method. Example : Consider the scheme Sa (VW, Xy%Q Suppose, the following F.D holds Suis wh ZoV,WY, XY> Z, U> WX oustity et bade oe following decomposition of scheme Sis lossless join decompositio; (S,=(V, WX) 4 (i) S,=(V, ¥, 2)ul Normalization 163 Matrix S will be v w x ¥ Zz Ss a1 12 13 oh Oleh. isl meta y baa 2) 94 a After applying functional dependencies, we get matrix Sas v Ww x v6 Zz Sy hy So, Bs Pry Dis Sy || 03 a a, %, %s Since second row filled wi decomposition. (9S, =(V, W, x (i) S = (X, ¥,2) Matrix S will be ith all a’s, so we stop. Hence decompositio; lossless join v w x ¥ Z Si an 12 413 bia bis Ss by by 5 44 5 After applying functional itependencies, we get matrix Sas 4 w x 3 Zz oH a S12 a3 big a5, S bay bay 3 O54 ie There is no row filled with all a’s and Bs, Hence the decomposition is lossy join decomposition, 5.4. NORMAL FORMS SS NORMAL FORMS — together, should possess. These would include two propertice 1. The lossless join or non-additive join property, which guarantees that the spurious Spe Beneratonproblems does not occur with respect to the relation schemas created after decomposition, 2. The dependency presentation, which ensure that each FD is represented in some ~ individuals relations resulting after decomposition n.agement System js extremely critical and must be achieved at a fal erty ‘i i ; di tive foreseen property, although eal is sometimes sao whereas the ve soning tbe fi of higher normal form rethon® as a base Tela, 4 ae ae name normal fo: is known as ‘Deno: i * which is in sore normal forms, which he called first, second an Initially, Codd ProP™ nition of 3 NF, called Boycee-Codd Normal Form (By LA aT and Codd. All these normal forms are based on the f 2 a by Boyer attributes of 2 relation, Later, a fourth normal form (ANF
| STUDENT_ID | STUDENT_NAME SUBJECT_NAME] GRADE [ STUDENTID SUBJECT Table—> [STUDENT_ID Inessence, INF calls for the atomicity of data (one fact i D per field, bs smaller parts without losing meaning), and the elimination of ate ane of data through the creation of separate tables of related data.5.4.2. Second Normal Form To be in 2NF, a table must be in First Normal form and no attributes of the table should be functionally dependent on only one part of a concatenated primary key. Thus, 2NF can be violated only when a key is a composite key, or in the other words, one that consists of a more than one attributes. 2NF is based on the concept of full F.D. A. F.D. X > Yis a full F.D. if removal of any attribute (A) from X mean that the dependency does not hold any more. That is, for any attribute AI X,. X - {A} does not functionally determine Y.A. FD Xe Y is a partial dependency if some attribute A « Xcan be removed from X and the dependency still holds, ie., for some Ae X, (X-{A)) > Y. The test for 2NF involves testing for FD whose left-hand side attributes are part of the primary key. If the primary key contains a single attribute, the test need not be applied to all.,A relation schema Ris in 2 NF if every nonprime attribute A in Ris fully functionally dependent on the primary key of R., Second normal form depends on the concepts of the primary key and functional dependency. A database is in 2NF if it is in INF and every attribute is fully functionally dependent on the primary key. Thus, the relation is in INF with no repeating groups and all non-key attributes must depend on the whole key, not just some part of it. Functionally dependent means that given a primary key, the value of any attribute can be retrieved For example, in the above mentioned example, if the STUDENT_ID is given the value of STUDENT_NAME can be obtained. Hence, STUDENT_NAME is functionally dependent on STUDENT_ID. EXAMPLE 5.12. EMP_PROJ SSN PNUMBER | HOURS NAME | PNAME PLOCATION FD, j FD, FD, Relation Not in 2NF EP, EP, EP, ssw | enumpen [Hours | ssn | enave ] _ [Pwumpen [pnaMe] pLocarion | FD, [a J FD, FD, f j Relation in 2™4 Normal Formo- Domain Database Management System value from { Domain usd tested easily EXAMPLE 5.13. Domain ar {iis pe jerNo. | Title Ss ae “a Computer Networks 250 ee . Graphi _ Neale 1. ee ; ae ' ee 2. Multimedia 300 ind a Thus, if we a Data structure 55d name and ‘ DBMS 295) Soe, 3. Multimedia 300 ‘aa 3, ‘Computer Networks 250 compariso} permits de ‘Relation Not in 2NF ‘ 3 | ihe a eore nie cence nce The ‘The above table lists the various orders of compu a : satisfied t wee eet poole and tho unit prion of eRe Hos nat eee tat the primary key eince bath orton or feat title can repeat in the table. This table isin am aes normal form as every ‘attribute is atomic, but ‘tle notin second BOT ea because Fait price ie vot functionally Gependent on order NO, part of the concatent, ea primary Key, but only on the ttle emonent. Quantity on the no Pe hand is functionally dependent on connected primary Key: , Tecan be seen that the prices of some books are repeated because 2 title can be orderea in multiple orders. For ‘example, the title SDIMS' exists in two orders order_no Land order no 3. Thus if the prices of this book is to be updated then we have to update it in all ce rresponding entries in the table. Moreovere if we want to add a book to our library, then cols of this book can Pe Nes Mere until onl ordes JS)Plner hia bole tectities suppose, order_no 2 is « ancelled, so we have to delete this order from the database, which ‘he information about that book including the price of the book, we have to decompose it in {Wo tables as follows : qnty.) and will loose all t For this table, ORDER MASTER to be in 2NF, ORDER MASTER (order_no, title, until_price). BOOK MASTER (Title, Computer Network Graphics DBMS Multimedia — Data Structure DBMS, Multimedia Computer Networks Sere etCormatizaton ) BOOK_MASTER 67 Title 5 UNIT _PRIC! Computer Networks Baul = Graphics DBMS Ae Multimedia ae Data structure ee Relation in 2NF p ‘ll the problem, of deletion, insert 5.4.3. Third Normal Form A relation is in 3NF, ifit is in 2NF and no non-pri ? ‘Prime on other non-prime attributes. © attributes functionally dependent It is also define as a relation is in 3NF, if it is in ONF a: : eT should be transitively functionally dependent on the primary key, utes of the tabla 3NF is based concept of transitive dependency. A functional dependency X--» Yin a relation schema R, is a transitive dependency if there is a set of attributes Z that is neither a candidate key nor a subset of any key oR and both X > Z and Z> Yhold. i A table is said to be in Third Normal Forms if all the non-key fields are independent, ie, no two non-key fields of the table depend on each other. The 3NF goes one step further in removing redundant data by removing field that are not wholly dependent on the primary key. In essence, 3NF seeks to eliminate all attributes from a table that are not direcvtly dependent upon the primary key. Hence, a table is said to be in 3NF if and only ifit is in 2NF and every non-key field is non-transistively dependent on the primary key. Consider the following PROJECTS Table. PROJECTED ID MANAGER ADDRESS P, Susan Park Street Q P, Janet High Street P, Susan Park Street me P, Susan Park Street PROJECTS TABLE In 3NF, we are looking for data in our tables that is not fully dependent on the primary key, but dependent on another value in the table. In the PROJECTS table above the ADDRESS field is dependent on the MANAGERS and not the PROJECT_ID. To bring this table into compliance with 3NF, a separate table base on MANAGERS is needed. Hence,Domain value from Domair tested casi] Domair It is pe customer-r names. Ho Itis perhar Normally ; “Find € Thus, if wi name and So, De compariso permits dc The ch satisfied E Query the PROJE! pher for all and anotl pROJECTS TABLE tabase ‘Management System gplit into two, one with the transitive q e Pendeney f table needs to be n CT al of the remaining attributes ns PREOJECT IP MANAGER Py Susan a Janet Susan Ps Susan MANAGERS TABLE MANAGER ADDRESS Susan Park Street Janet High street Tables in 3NF The determinant attribute becomes the primary key in the new table, i to the MANAGERS table. The original key he MANAGER utes—in this case, PROJECTED ID ha ID remaing the ‘anager’ field becomes ining non to the remal key to the ne’ address, it car between the are now in For exam, EMP_DEPT, because DMGRSSN hold and D EXAMPLE 5.14. EMP_DEPT ENAME ssn | BDATE /ADDRESS| DNUMBER ED, Ww n be looked up in tl in the PROJECTS ‘Third normal form. the primary key -transitive attruibi e address is stored only once. he MANAGERS table. The MAGE Se eis the ling PROJECTS table. Now the table, it is now a forei, ign key. The: Se tables two tables, and i dependency SSN > DMGRSSN is transitive th dependencies. SSN > ENUM BERIEEAES a nor a subset of the key of Sra A PT. both the iple, the NUMBER is neither a key itself DMGRSSN ED, DNAME | DMGRSSN Ppoonessfonwoe] fi DNUMBER |! t [ ENAME | ssw [aoare valu fo arf ol Relation in 3 NF —————— ~—S—“‘i‘i rTDD EXAMPLE 5.15. ie Course Name Head-Deptt. Room No. Room-Capacity B.Tech (CS) Prof. Gupta 102 60 B.Tech (IT) Prof. Smith 107 50. B.Tech (EC) Dr. Sundaram 105 60 B. Tech (Al) Dr. Srinivasan 103 100 MCA Mr. Sharma 11 40 Relation not in 2NF In the above relation, room-capacity is functionally dependent on room_no and room_no is functionally dependent on course_name. So a transitive functional dependency exists here. Room-capacity is transitive functioanlly dependent on course-name. COURSE_NAME—> ROOM_NO—> ROOM_CAPACITY ‘The Presence of this transitive functional dependency will cause the problems. The capacity of a room cannot be entered in the database un. less a course is scheduled in that room; and the capacity of a room in which only one course is scheduled will be deleted if the only course scheduled in that room is deleted. So this relation is not in 3NF. For this relation to be in 3NF, we have to decompose it into two tables COURSE and ROOM as follows : COURSE COURSE_NAME HEAD_DEPT ROOM_NO B.Tech (CS) Prof. Gupta 102 B.Tech (IT) Prof. Smith 107 B.Tech (EC) Dr. Sundaram 105 B.Tech (Al) Dr. Srinicasan 103 MCA Mr. Sharma lll ROOM ROOM_NO ROOM _CAPACITY 102 60 107 50: 105, 60 103 100 111 40. Relation in 3NF Consider one more table EMPLOYEE having the attributes (emp_no, ename, sal, dept_name, dept_location). In this relation, emp_no is the primary key attribute. Dept name is the determinant of dept_location and being prime key attribute, emp_no is the determinant of dept_name. So, a transitive functionally dependency exists in between dept_location and emp_no.Database Management System TION | Domair value from rT "au t ied cail EMP_NO—> DEPT_NAME—* DEPT_ es Donal EXAMPLE 5.16. ae aeration eS ¢ Sal Dept! see 5 It is pe | emp no. E-Name Ea ‘ customer-t 1001 Vishal 7500 hes vat names. Ho ee Ait 5000 4 as It is perhar a4 ea rian ee a a Normally ( ue cae bead oi 104 “Find € ae Thus, ite 1005 Sumit 6500 name and / So, Da Not in 3 NF. assay Nama Dept Location 4 compariso d remove the transitive dependency vermits de To make it in 3 NF we decompose a” The cl Emp No — Dept-Location Petre | atisfied b Query Vishal Amit Anuj | Vikas d 2 aie ! Sumit 6500 ae Department shee’ Dept-Name Dept-location Accounts 102 Sales 104 Store 106 ue Relation in 3 NF LOTS ANF LOTS1 LOTS2 2NF LOTS2 SNF LOTSIA LOTS3B. Summary of normalization of lots (UPTU, 2002, 2006) 5.4.4, Boyce-Codd Normal Form (BCNF) BCNF is an extended form of 3 NF. If a relation is BCNF then it must be in 3NF. In BCNF we extend our concept up to all the candidate keys of the relation, which are concatenated and two or more of the candidate share a common attribute. eTi BCNF, a table must only have candidate key as determinants”, i * dd normal form (BCNF) was proposed as a sim, tricter form of 3 NF, because every relation i Rin of BCNF differs slightly from the definition if whenever a nontrival functional dependency pler form of 3 NF, but it was n BCNF is also in 3 NF. The of 3 NF. A relation schema R X— A holds in R, then Xisa functional dependency if, all ictional dependencies in F* of the form o 8 where © Rand fc R, at least one of the following holds. > fis a trivial functional dependency (Le, Bea) @ is a super key for schema R. ple : Consider an example that is not in BCNF. bor_loan = (cust_id, loan_no, amount) olds on bar_loan, but loan_no is not msortium of many customers). - The functional de pendency loan_no > amount a superkey (becau: se a loan may be made to a Example of BCNF : Stud_ID S_Name Subject Grade 1001 Axay Physics A 1001 Axay Chemistry & 1001 Axay Maths iG 1002 Sparsh Physics, A 1002 Sparsh Chemistry A 1002 le Sparsh Maths B Relation is not in BCNF In this relation following FDs exist : S_NAME, SUBJECT —, GRADE STUD_ID, SUBJECT —, GRADE SNAME —5 STUD_ID STUD_ID —, S_NAME ition. The rule for a relation R, which is not in BONE, ig as follows : Let XR, A be the single attribute in Rand X—> Abe an FD that causes a violation of BCNF.ve 1.4.4, Bc? CNF ¥ neate i XA. in BCNF, ‘SUBJECT Physics Chemisty Maths Physics chemistry Maths Decompose Rinto RAand jation to be the decomposition will be as follo So, for above rel __ GRADE w>p>aa> NAME 7001 “Axay 1002 Sparsh pep sal ‘Relation in BCNF 55. MULTI-VALUED GEPENDENGY AND FOURTH NORMAL FORM dent multi-valued facts about th neraily, it is denoted by 'e same attribuy iti valued dependency of Yor X* and m, and more indepen’ More ge! “there is a mul occurs when two or nthe same zelation- readers MVD occur withit x 5 > ¥ and will be determines a eyby denoted by >.» epecttieala i Fp specifies the following ee schem, such that (X) = (09, then two vo rties, where we use Z to one ‘e Multivalued dependency ( where X and Y are poth subsets of ror R: If two tuples 4 ‘and ¢, exist in Ts should also exist in rwith the following prope! 1, (39 = GIA) = A) = 209 #4, (9 = 40) and 40 = 99 +4 = HQ and 44 = 44 An MVD X— Yin Ris called ‘An MVD that satifies neither (a) nor (Bis a trival MVD if (a) Xis a subset of X or () XU ve 5 called a nontrival MVD. (0 XO For example : Relation with MVD Faculty ‘Subject Committee DBMS _ Placement Ne ear Placement eas Placement ae » Scholarship pete Scholarship Scholarship@ Multi-valued dependency (MVD) occurs when two or more independent multi-valued facts about the same attribute occur within the same relation. More generally, MVD can be defined as follows : Let R be arelational scheme and let Xand Ybe the subsets of attributes of R. Intutively the MVD X > > Yis said to hold over R if, in every legal instance rof R, each X value is associated with a set of Y values and this set is independent of the values in the other attributes. Intuitively, a raulti-valued dependency is denoted by X > + Yand will be read as “there is a multi_valued dependency of Yon X” or “X multi-determines Y”. Fourth Normal Form A table is in 4NF, if it is in BCNF and it contains no multi-valued dependencies. Arelation schema R is in 4 NF, with respect to a set of dependencies F (that includes FD and multivalued dependencies) if, for every nontrival multivalued dependency X—>» Y in F*, Xis s superkey for R, Consider again the same faculty relation with MVD. Clearly a faculty has multiple courses to teach and he is leading several committees. This relation is in BCNF, since all the three attributes cancatenated together consitutes its key, yet it is clearly wrong and requires decomposition, The rule for decomposition is to decompose the offending table into two, with the multi-determinant attribute or attributes as part of the key of both, In this case to put the relation in 4NF, two separate relations are formed as follows : FACULITY_COURSE (FACULITY, COURSE) FACULITY_COMMITTEE (FACULITY, COMMITTEE) For example; Faculty Course Faculty-Committee John ‘Subject John Placement _ John Networking John Scholarship John MIS Relation is in 4.NF 5.6. JOIN DEPENDENCY AND FIFTH NORMAL FORM (UPTU, 2005) ‘A join dependency (JD), denoted by (Rj, Ry, R;). Specified on relation scheme R, sepecties a constraints on the states rof R. The constraint states that every legal state rof R should have a lossless join decompositon into R,, Ry, --» Ry ‘That is, for every such r, we have * (Tal), pale)» --» Healt) = 1 Notice that an MVD is a special case of a JD where n= 2, ie. a JD denoted as JD (R,, R,) implies an MVD (Rj 0 Ry) > (R, = R,). A join dependency JD (Rj, Ro, ..- Ry), Specified on relation schema R, is a trivial JD if one of the relation schemas R; in JD (R;, Roy « R,) is equal to R. Such a dependency is called trivial because it has the losslessjoin property for any relation state r of R and hence does not specify any constraint on R.Pfs. TION PR ONCEPT TS Tnside this Chapter 6.4, Transaction System; 6.2. Properties of Transaction; 6.3. Transaction State, 6.4. Transaction | processing System; 6.5. Recovery from Transaction Failures; 6.6. Distributed Database; 6.7. The Major Advantages of DDBMS; 6.8. Transaction Processing in DDBMS: 6.9. Data Fragmentation. core tte ieee apsinetaiah &.1._ TRANSACTION SYSTEM iEPTU, 2006) “Collections of operations that form a single logical unit of work are called transaction.” ‘Atransaction is a unit of program execution that accesses and possibly updates various data items. It is also define as a logical unit of database processing that includes one or more database access operations. ‘Transactions access data using two operations : 1, Read (X) : Which transfers the data item (X) from the database to a local buffer belonging to the transaction that executed the read operation. 2. Write (X): Which transfers the data item (X) from the local buffer of the transaction that executed the write back to the database. " 6.2. PROPERTIES OF TRANSACTION (UPTU, 2003, 2006) (Imp.) Transactions have four basic properties, which are called ACID properties. These properties are closely related to each other. A Atomicity C > Consistency I Isolation D > Durability 183 ,jetely. OF Not 6.2.1. Atomicity oP) _— com? “rion wil ‘A transaction is an atomic unit of processing: It ig either perfor’ pansaclc, ee performed atall. At the need of a transaction the updates made bY accessible to other transaction. | | 5 in a consistent 6.2.2. Consistency wa! .s that if databaractions the database ‘The consistency property of a transaction implies state before the initiation of a transaction, then at the end will also be in a consistent state. 6.2.3. Isolation steps OF operations performeg ti ‘The isolation property of a transaction indicates that he ution of 2 transaction, Zated concurrently. bya transaction should be isolated from other trans: should not be interfered with by any other transactio! 6.2.4. Durability ae ansaction must persist in the | ‘The changes applied to the database b: } database. These changes must not be lost bece! ts are there and @ set of transactions | C-I-D Properties Example ‘Example : In a Banking system there are 2% nts ewe assume that the datal Me ig temporarity residing in main, | that access, and updates, those accounts. permanently resides on disk, but that som memory. i database : ‘The following two opearations are accompklished to acces the/database + Fead (X), which transfers the data item X from the database to. local buffer belonging to the transaction that execuited the read operation. + Write (x), which transfer the data item X from the local buffer of the transaction, that executed the write pack to the database: In real Database system, the write operation does not necessarily result in the imm eda update of the data on disk, the write operation may be temporarily stored in memory a executed on the disk later. However We shall assume that the write operation updates the database immediately. T, be a transaction that transfers $5! 7, : read (A); A:=A-50; write (A); read (B); =B+50; Write (B). portion o 0 from Account A to acount B. This is defined as Applying Acid Properties 1. Consistency : Here consistency req. is that the sum of A and B be un the execution of transaction.wy Transaction Processing Concepts ut) 2. Atomicity : Let A= $1000 B= $2000 If failure oceures after write (A) operation was executed but buffer writ avas executed, In, this. case, Me valucobaccouatA and Birellected in hs (B) operation $1950 and $ 2000, Here we destroy $ 50 as the result of failure and ig detahase are sum A +'B not Preserred. ‘To ensure atomicity, the database system keeps back (on disk) of th hhich a transaction performs a write, and, if the transaction di le old value of any ceceution, the old values are restored to make it appear as though th loes n sXeouted. Atomatic ensures by transaction management comp, Rene we 3, Durability : The durability property guarantes not, once a trans, action complet es all updates that carried out on the database persist, even i he transaction completes execution. To ensure durable thereis a system 4 ' ot Complete its data on wi sactions never- successfully, failure after tl 1, The updates carried out by the transaction have been transaction completes. written to disk before the 2, Information about the updates carried out by the transaction sufficient to enable the database to reconstruct the updates SHEAR restarted after failure. Durability Ensures by Recovery Mtaiagsinehe de system is. en 4. 18olation : If consistency and atomicity properties are ensured for cele ‘eral transactions are executed concurrently them operations Se ble way resulting in an inconsistent state. may interleave some Two transactions executing concenrrentl i ly: may interleay ‘ B property.is not obeyed Ta solve it concurrently executing transaniene ictions is if'se undesiral Example : value and A + execute serially. i @.3._TRANSACTION STATE ‘pctive! It is the initial state; the transaction stays in this state while itis executing, partially committed : After the final statement has been executed, Fig. 6.1, State diagram of a transactionstored s been te ‘Aborted : After the transaction has been rolled back and the database D& to its state prior to the start of the transaction. pally 38 said to be Committed: A transaction that completes 1t8 execution succes? committed. eed no longer PM Failed : After the discovery that no ESSING SYSTEM rmal execution Cc! targe siz database and ‘s aiway reservation 6.4,_ TRANSACTION PROC! Transaction processing systems are the systems, which include pias 19 use same database concurrently- Hoes mem iS ‘called transaction other i allows many users t stem oF system, Banking, Credit card processing SY" 6.5. RECOVE A computer, like any oth failure, including power information pertaining to di ‘A recovery process is an integral Part © detection of failures and recovery of database. ‘There are two types of failures * L. Loss of Volatile Storage : Itcan Dé r based recovery, Buffer managements ! . Non-Volatile Storage Loss : The most PoP the entire database to a stable storage perio database to one or more magn: js used in restoring the database. chniques of recovery. er device, is subject to failure, disk crash, 5 atabase system is lost: | ‘There are various te’ ack 6.5.1. Cascading Ro ‘The phenomenon, in which a single transaction processing system. RY FROM TRANSACTION FAILURES failure. There may B oftware e170! fa database covered U! ‘checkpoints ular ically For &* etic tapes. Ifa (UPTU, 2006,07) e several cause of such mY | n,cach of these ceca system, which is responsible for various methods. example, a shadow paging techniqact nomical scheme is to dum, ample, we may dump Pp the most recent dump sing an and €0O! failure occurs ip & failure leads to a Series of tr ‘ANSAction rollback, is known as “Cascading Rollback.” | For example ! 1, I y | Read (X) Read (Y) X+Y write (2) 7 Read (2) s write (Z) 7 Read (Z) Transaction T,, writes a value of Zis read by transaction T. Pp writes a value of Z, that is read by transaction T, 2 Transaction > hsuppose that, at this point, 7; fails, 7, must be rolledback, § ack. Since T, is de ty must be rolled back. Since T, is dependent on Ty, Ty must also be rollen eet 4.5.2. Recoverable Schedules so be rolled back. a h Read (X) |); alee write (x) Read (x) Read (Y) in this schedule 7, transaction performs only one transaction suppose that the system allows 7; to commit immediate cage pstruction. It means 7, commits before 7,. Now suppose that 7; fails before it commits, Since 7, has alread (99 written by 7}, So itis necessary to abort 7, to ensure transaction mens the data item However, 7, has already committed and it cannot be aborted. new a situation where it is not possible to recover correctly from the faihine we eo Hence transaction processing system must ensure that it is pos ‘ the failure of any active transaction Possible to recover from 6.5.3 Log Based Recovery ‘ (UPTU, 2004, 2007, 200 To keep track of the database transactions, the DBMS maintains special fler ai 8) files or journals that contain information about all updates. The log fle contarne eae o8 tike transaction identifier, type of the log record etc, ‘ains information since the information contained in the log files are critical for the two separate copies are maintained. In the past the log files were Hoda aaapeene fapes. But nowadays, DBMS are expected to recover from minor failures very quick wea fo the log files are stored online on a fast direct access storage devices (DASD), ae Since the online log files are also prone to failures, the log files are periodically archi and are stored in off-line storage, These log files are called “archive ig ai ly archived ly after excluding the read (x) arrived in. Log ‘The most widely used structure for recording database modifications is the log, Th js a sequence of log records, recording all the update activities in the database, Tete several types of log records. An update log describes a single database write, It has these fields: Transaction identifier is the unique iden write operation. bata item identifier is the unique identifier of the data item written, Typically, iti the location on disk of the data item. . #old value is the value of the data item prior to the write. he value that the data item will have after the writer. records exist to record significant events during transaction processing, we denote the ier of the transaction that performed the #New value is t Other special log : nas that start ofa transaction and the commit or abort ofa transaction, sucl various type of log records as:Database Management Syste™ T, d valu * <7, start.> Transaction T; has started. gata item Kp Ee + <1LX, Vy, V_>. ‘transaction 7; has performed @ W'S 0 V, before the write and will have V, after the write: * <7, commit> Transaction 7; has committed * < Tabort> Transaction 7; has aborted. It is of two types : (i) Deferred D.M. ae (i), Immediate D.M- +> aden technique & (i) Deferred Database Modification : The deterred ein jog, ut defer ng transactio tomi Jing all database modi faction Pa ; ransaction atomicity by recording all dav i until the tare’ the final actions oh eta nique that execution of all write operations of a alte Recall that a transaction is said to:be partially.come - odinication Hes Re eaiaction has been executed. The version of the defer™ ted serially. Trae tion hie ecction assumes that transactions ATS SS" ace 7, followed by ‘Suppose that these transactions are executed serially, in {PF ook place were $1 na thot the Jalilea of accounts A, Band C vcore thc <1 e, tng the relevene informe $2000, and $700, respectively. The portion of the le8 OO", orders in which the ac eae cec tol rar soeione appearsin Agure: there 80 7 saaateiresulUor ene cae cutputs can take place to both the database system Mm of Ty and T;.
<7) A,950>
be (ii) Immediate Database Modification: The immediate modification technique databhee modifications to be output to the database while the transaction is still active state. Data modifications written by active transactions are called uncon failure, the system must u se modifications. In the event of a crash or a transaction i value field of the log records described to restore the modified data items to the val had prior to the start of the transaction. The undo operation described next, accon this restoration. Log Database < To start >
< Tp B, 2000, 2050 > A= 950 < Ty commit > B=2050
< Tp commit >as) __ gyre shows one possible order in which the actual outputs t i mies ‘and the log as a result of the execution of T, Ee ATR ne gota! te ints checkpoin (uPTy, \ ? 1 i, 200: 658 checkpoint is @ po of synchronization between the database and the transact “ _iffers are force-written to secondary storage at the cl is ction all heckpoint. Checkpoints jog file: ied syncpoints or save points. c ae pel nedules at predetermined i i ints are schedules at predetermined interval and involves o cco gngnelmemnnno messed eer ee erations like writing all ae transactions are executed serially, when a failure occurs, we check d the transaction that started before the last checkpoint, ck the log file to fin 6.5.5 Backup Mechanism “ base can be used to recov backup copy of the datal Be patie database oF incremental copy: An incremental backup consist only me entire date tne last complete or incremental backup, ee 6.5.6- Shadow Pa! i 9. " (UPTU, 2008) ‘the shadow paging scheme does not require the use of a log file in a singl est hough a log is needed in multi-user environment for concirenty SRE ee nen geonsiers the database to bemade up ofa numberof ixed-size disk or disk blocks for recovery Purposes. es ‘the shadow paging technique maintain two directories (two for each database page) quring the life of a transaction—a current directory and a shadow directory. When the transaction starts, the two directories are the same. The shadow directory is saved to the tip and the current directory is used by the transaction. The shadow directory is never Ghanged and is used to restore the database in case of a failure. During the transaction execution, the shadow directory is never modified. Backup Database Media Failure Check points. Recovered Restored Database Database Restoring and recovering a database,Z 4 ee : ABILITY AND- K-HANDEING Ya, Inside this Chapter jalizability of les; 7. rial 'y of Schedules; 7.2. Types of Schedules; 7.3. festing of Seriali 3, erializability; 7.4. Se 7.4, Deadlock Handling; 7-5. Deadlock Detection; 7. . ; 7.6. Recovery from Dea idlock. 7.4. SERIALIZABILITY OF SCHEDULES (UPTU, 1, 2004, 2006) (Imp.) fwhen several transactions are executing concurre Re ee deta ntly then the order of execution of various ‘The concept of serializability of schedules is used to identify which schedul when transaction executions have interleaving of their operations in fe ached’ aaa schedules. eee 7.2. TYPES OF SCHEDULES —_ 1. Serial schedules. "9. Non-serial schedules. 3. Conflict schedules. 4, View schedules. 197e read-ite™ (X) = Serial Schedules 1 ID ; Xext Mi read:item (X) , item (X) XiKNG write-item (X) write-item (x) read-item (Y) 5 YiY+N: ‘waite-item (Y) ‘ \6 item (X) & ey. aN f waiteitem (Y) ? peter schedule B Schedule A erations of each transact .dule if the oP* .d operations from .ed in serial orde the other transactic called serial sche + T, and then T, or ‘two schedules Aand Bare : are executed consecutively, without any interleave’ Ina serial schedule, entire transaction ar¢ performs and then T, Non-serial Schedules ‘ ; ‘two schedules C and D are called non-serial schedule if the operations cee trans ectien are executed non-consecutively with interleaved operations from the ott transaction. 1 readitem (X) ; X2XNi i) ut ue read-item (xX) 7 XiX+Mi Write-item (X): read-item (¥) + write-item (X) : YiY4N: waite-item (Y) : Conflict Schedules : i i ee les: The graph which contains no cycle is called conflict serializa If the pre ae eee graph for Shas a cycle, then schedule S is not conflict serializal ph contains no cycle, then the schedule Sis conflict serializable.”Serializability and Deadlock Handling 1, For each the transaction hn data item %, if transaction 7) executes, eradtemoXsaftranse Lee amet chiet ce must, lle S, also read the iniual valug cognate Si» , For eae For each roused by wansaction 7 fan a (A) in sched z T (if any), then trans: lens zat ene HAG tno Fa also rea hh data item X, the transaction (if n (if any) th of view equivalence leads to th PRrratan a te concept of view equivalence 1 concept of schedule 5 a achedule Sis ew cevilizability fis vew equivalence rag gerbe We say th ey confct-srializabity schedule 19 also view bari estas ‘ cctisable schedule that are not conflict serializable. wuaable, > wie z 7a,_DEADLOCK HANDLING aon (UPTU, 2006, 67,08) ip aaid to be in deadlock state when in a set oft i fpother transaction to finish its operations, sive action 7, Performs the fi 3, For ea! final write (x) coperatior but there are view Asystem : ms, every transaction is waiting £0) ‘Adeadloc! ‘each waiting fOr ‘There are two Pt 1, Deadlock prevention protocol ection and recovery process. {kj a state of statement that may result whe ig Hild By the other ts be velegacd: 94 Hate rincipal methods for dealing with deadlock problems» lore transactions are 9, Deadlock de _ peadlock Prevention Protocol : This protocol ensures that the Ziatoce state There ar diferent methods that canbe use for deailoce oe ig he simplest acheme fequires that each transaction locks allt data roa starts execution. fata item before it 1p Another method forthe prevention of deadlocks toimpose ' ter mentor vt toe ae ee ne order specified by partial order. ‘Another approach for the prevention of deadlock is to use pre-empti / iption and transaction rollbacks. n and Recovery : Ifa system does not imply some protocol that a 2. Deadlock Detectior then a detection and recovery scheme must be used. ensures deadlock freedom, ____—_—__—___—_=EcTION JETECTION (UPTU, 2007) 7.5. DEADLOCK DI Deadlock can be described precisely in terms of a directed graph This graph consist of a pair G=(V, B), (=)\—€s) called a wait for graph. f vertices and Bis a set of edges. Each element where Vis a set 0} iges is an ordered pair T;—> 7, If 7, Tis in E, @) n the set Eof edi hen there is a directed edge from transaction T; + 7p implying hat transaction 7; is waiting for transaction T; to release a data (ia) ‘em that it needs.m ifand ‘A deadlock exists in the syster transaction involved in the cycle is said t ‘This wait for graph contains a eycle: Hence Tao 7.6. RECOVERY FROM DEADLOCK When a detection algorithm determine: from the deadlock. The most common break the deadlock: There actions nee 1. Selection of a Victim to roll back to break the dea‘ incur the minimum cost. sol dt 2. Rollback : Once we have deci back, we must determine how far solution is a “total rollback". Abo! is more effective to roll back the deadlock. Such partial rollbac information about the state of all 3. Starvation : In a system where sel 4 tin cost factor it may happen that the some transaction, 12 ——— SOLVED EXAMPLES oman ree 2, ‘Database Manag\ 0 be deadlocked. g that a deadlock exists, : In this we determine dock. We should F ided that a particull this transaction SH0" only if the wait for graph con’ Tyqs Taq are all dea lution is to rollback one or mi jo be taken : ee wentin transaction (or ens Cr stout tions that will oliback those transact on-must be rolled sijd be rolled back. The simplest ion on and then restart.it. However, it iy ae far as necessary to break the Wy Gystem to maintain, additional tions. for rollback, is based on always picked up, jar transactic rt the trans transaction on! ¢ requires th || the running transact lection of transactions, dule is a conflict serializable ? For each, EXAMPLE 7.1. Which of the following sche tested aevlutigable achedule, determine its equivalent serial schedule: Solution : (a) r,(X); 75(X); Wy; r21%)3 Wal) q, T, Ty (X) 1X) WX) 1(X) c wx) Fig. 7.9:NN or Concurrency Control; 8.5. Graph Based Protocol; S,omas Write Rule; 8.8, Modes: Intension | || e.1. concurrency | g.3. Mode of Locking; 8.4. es ing Protocol for Cone pee orate Sfuitiversion Schemes; || 8.6, Time Stamp’ | Protocol; || .11. The Multiple-Granularity: |] 8.13. Multiversion ‘pimeStamp Pro! @:1._CONCURRENCY CONTROL. he mi ent of concurrent transaction execution. DBMg Ht ofp ensure cerialien DI and isolation and integrity of the database: of the DBMS, with various methods such based techniques and optimistic meth oil jmultaneous operations (querj 3 them interfere with one ancl hy currency control is th implement concurrency control imp gaction in order to guard the consistency Concurrency control can be performed by locking methods, timestamp methods, validation _ Concurrency control is the process of managing § updates, inserts, deletes) 07 the database without having, ‘The objective of concurrency control is similar to the objecitve of multi-user c eystem where many users can performs Sjferent operations at the same tims omputer systesm the different users are cilowed to perform different actions ninulancoen : in these sly due to concept called multi-programming. @.2,_LOGKING TECHNIQUES FOR CONCURRENCY CONTROL LAG (UPTU, 2007) ccess to data. When one tran ionis used to control concurrent a a lock n lock may be deny access to other transactions to pre| vent incorrect Cont Lockingis a procedure accessing the database, results. j 208Concurrency Control Techniques he most widely used jgone ofthe most widely used mechanism t sas follows : A transa 0 ensure se, isa A transaction must obtain a reaq 2 ying ie of loa crform a read or writ ; s priciPle van Pen rite operation. add cart ag jes for locking are : ity. The working clock on a dats erul ihe basi he basi action has aread lock on a data item, i it can read th € item but not Update action has a read lock on a data it item, other trar Nnsactio, a trans 2. ead rapion the data item, but not write locks, nS Can obj : tain a ay ata transaetion has a write lock on‘a data item. It can both ata iter Fead and update th tion has a write lock on a data i 7 ans k ata item, 4, Ifa wanetea read lock or a write lock on the data tienes cana cannat tem. oe vamonly used technique to control the concur saost emash look on a data lem species erurency is based on the conceptot jock operations like oe id anawrite that can be Applet Sibsite eee a ae opersrem, a lock must be associated with that item. Ifa ‘a transaction Twants to iy Gy accesses the same data item, 7, has to wait unt 7 ges up theiecn GH 7, locks the data item. ? gives up the lock. Otherwise {ODE OF LOCKING a ‘two modes in which a data item may be locked : (UPTU, 2004) rere are mainly 1, shared lock 2, Exclusive lock. 1.9.1. Shared Lock i, onsection T,has obtained 4 shared znbde lodicon ier item Q, then 7, can read " but annot write Q. Itis denoted by (S)- on 1.3.2. Exclusive Lock *y, ransgction Tjhas obtained én ex-tusive-mode leceon ‘write 0. It is denoted by (%)- tem O, then jean both read nd THE TWO-PHAS! PI es iE E LOCKING PROTOCOL —— = (wrrv, 2004, 2006, 2008)fmp,) 4. ing protocol ensures serializability. This protocol requires that each ne two-phase lockis he faction issue lock and unlock requests in éwo phase: 1, Growing phase 2, Shrinking phase 1, Growing Phase : In this phase a transaction may obtain locks but may not release sy lock. Here the no. of locks increases from 2¢r9 to the maximum for the transaction. 2. shrinking Phase: In this phase a transaction may release locks but may not obtain wy new locks. Here the no. of locks decreases from maximum to zero.Database Management S 7 There are three types of two-phase Jocking protocol 0) Conservative Two-phase Locking- (p) Strict Two-phase Locking. (9 Rigorous ‘Two-Phase Locking. 8.4.1. Conservative two-Phase Locking It requires @ transaction to predeclare all the locks it requires before its execution. Ifany of predared items cannot be locked the transaction waits until all item are lockeg, free but it is difficult to use in practice. i the locking protocol is deadlock 8.4.2. Strict Two-Phase Locking In this protocol a transaction does not release any ofits write locke untill it commits aborts. or Rigorous two-Phase Locking ck and read lock untip j it tocol, transaction does not release 2nY of write lo 8.4.3. In this prot commits or aborts. cor @.5._GRAPH-BASED PROT — PROTOCOL rderingon the set D= {d,, d. tap Gan 14} Of aly 8.5._GRAPH-BA! owledge, we impose a partial 01 tien accessing both d, and d,must MUST ACCESS defor, To acquire prior kné transact | data item. If d, > 4 then any 5 that the set D may now be viewed as a dir ected Acyclic accessing d; in this section, for the sake the simplicity, we wi » we wil ll restricy ‘The partial ordering implie graph called a database graph. o rattention to only those graphs that are rooted trees. ‘Tree protocl is restricted to employ only exclusive locks. only lock instruction allowed is lock - X. Each 4 transact ion 7 In the tree protocol, the can lock a data item at most once, and must observe the following rules : 1, The first lock by T;may be on any data item. 2, subsequently, a data item Q can be locked by T;only if the parent of Qi it is currently locked by 7;- 3, Data items may be unlocked at any time. 4. Adata item that has been locked and unlocked by 7, ‘The tree-locking protocol has an advantas : ; 2 wes over the two-phi i that, unlike two-phase locking, it is deadlock-free so no Behackoe seo Protocol in| pe te oe protocol has another advantage over the two-phas ns ie unlocking may occur earlier. Earlier unlocking may lead to ceate ae Cae iting tim 8, and to an increase in concurrency. However, i . the protocol has the disadvantage that in some cases, trans: , transaction ma ty have: by T,cannot subsequent _ is tly be relockeg to lock data items that it does not access.‘Concurrency Control Techniques en 76_TME STAMPING PROTOCOLS FOR CONCURRENCY CONTROL —~ sjampingis-« concurrency control protocolin which the Sarna peccgtcienent ce ant ote aner then. areas oF apie onesation Je allowed, only if the last updata on iubdae rae ihe by an oer ansacton. Otherwise the ansacon,requentin ee amperes irom continuously aborting and restating See eer sus method sequence of transaction is selected in advance by using the wrote ses tn Sr ce 1 system clock value, ie : neat mestamp value, We can also use a logical counter that i incremented after aiog toe gia transaction 7 has ben atagneda timestamp 9, and 9 sc eanbae ater ro he sytem witha time stamp value 8, then §,« Sand ayte il allow tha 1enfon 7, torn fst followed by the transaction 7, i sia aenaae aaa ifany cont une conflicting ‘there are two 4, wetime stamp (Q) 2, ReTime stamp (Q) 4, wetime stamp (Q}: Denotes the largest time stamp of any transaction arite (Q) successfully transaction that executed ig. Rtime stamp (Q}: Denotes the largest time stamp of any transact a ea yy transaction that executed > AS WRITE RULE THOMAS WRITE RULE B.7- “pe modification tothe time stamp-ordering protocol, called ‘Thomas write rule ‘Thomas write rae provide a modification to the timestamp ordering protocl reater potential concurtency, thatallows uppose that transaction 7, issties write (Q) Re a ae a ‘of O that Tis producing wet Teen eded and it had been assumed that the value would never be oud thc aystem rejects the write operation and rools 7, back, Hence, a Was (t) < Welime stamp (Q ten Ts attempting o write an absolute value of Hence, this write operation can be ignored. . 4, otherwise, the system executes the write operation and sets W-timestamps (9) to TS(T} ction is found between transaction using ti transactions is rolled back. 2 Snestanp badeslgyster/ ond at types of timestamps.Not EB child nodes. before, belttesent in more than one file. ‘each node in the tree can be locked individual ly. propriate granularity In multiple granularity locking, each transa ey avon moseert locking, each iction. 2 mode of operations. For this sc y bane y: heme we may consider adatabace eet hic 1¢ hierarchy of ‘Database Management Syst @.6._ VALIDATION-BASED PROTOCOLS ae cee’ ‘The two concurrency control techt control, another c ‘control techniques, One is locking based concurrency access rae cone ing baced concurrency technique. Butin both the echnid ey eel See ee ene ee IaeaLinieeie levels of drawbacks. In locking based techniques, the item being accessed must PT a Fre nmmber of 10K 1 be maintained would Increase causinghigher overhead: Méreoes ‘Aiso, here it performs the operations in two steps: In first tery it locks @) At hea more strat space is required as per example forread and, ae Which are required in transaction, and if all the items 9% Tocked success)" Dane peqoey Buasautblei cece ce Lae aga neincrease grteumeatampfoceachidsta aarcy phase, the data tems are modified. n timestamp bases {eennIaUS cee hence ‘ 's assigned a timestamp value and this transaction “aimeatamp 18 cheCKES TT stow ined sai tmestamps of the and io ee hes ease =a jese overheads. fata item directly to 4 DB—Datab: + lan Hon wae eBncIGAe 82 HOE EPIRIS 2 tog gat Sa er datahase, rather It keeps local copies ofall the UPdor dari ty of tion ang Ree a ereeineaction reaches its end, a validation POS) checks te te Io ey ote call Long agate items due to the “updates, and ifit is consistent #heP ‘all the da Beg, faerntas® Record to the database. tion any d : ¢ transac ata item Reading is done when required and if at te ead of the caine found to be inconsistent then the transaction {rolled back an cg optimistic) based coneurTen cy control technique, "2 : tree consist of four levels of nodes. sno tree conn 1s of nodes. The highest level re} pelow itare m type area; the database consists of exactly these mean Bachar turn nas nodes of Kisabitachiltentcatweea tte me ati (file is in fea contains “thar apeite sie etcn marta ea Ry ehcp les, and no record can three phase for validation ‘committed values from the dat eee vd and reads the last’ and purihesevalacs 8 to aden ta oly nese el este 0.8.2. Validation Phase chine Pree at wn is activat focal variabl values during the first phase 8ainy eified database should reat forit the various modes. fa node is locked in an intension m ae ce: tf , explicit locking i ilenin ckennn odie ae eee entire tree to determine whethe explicity. Thus, a transaction d on all the ancestors of a ffek a node say (Q) must ee ee eeatal At ae werse a path in the tree from the zoo eas wishing to © (Q). Whil g mode. i raveraiogs . for the read ¥ In this phase che tems are the current values. Also it the database in a consist tent mog, consistent. 8.8.3. Write Phase . «passed second phase leaving eo is ated othe database permanently Iin f serializability, so if discards, elle ithe transaction bal nd ln raeade bythe eansacton ar ten up age sin connie Wal .d transaction is ‘restarted. Janiques all the checks or validations are the tree, the transaction locks th pa | eee Te ie yadtts naner Rane 10, INTENSION MODES all the updates an‘ rrency control tec ‘ead phase, transac In optimistic concu "Before that in e transactions that access oo 160856 the databy|_ There are three types of intension modes: 1. Intention-Shared (IS) mode. once in validation phas overhead. ‘So, this technique is very much suitable foF for andi only operations and modifies disjoints sets of data item. (Orr a 2, Intention-Exclusive (IX) mode. 3, Shared and Intention-Exclusive (SIX) mod: le: Ipention-Shared (1S) Mode eS eS MULTIPLE GRANULARITY data item being locked. Granularity is consi it can effect the performance of con wel 9.40.4. I Ifa node is locked in intention-+ ntion-shared (IS) mode, explicit locking is being d . ig done at a lower a9. By granularity we mean is the size of the factor concurrency control because i data item is very large then overhead @ evel of the tree, but with only shared, mode I : lor: as the major: na recovery. Because, if the granularity of a locking is very low but it will effect the concurrency.nvion-Exctusive (1X) Mi wee mtention exctuave FX) Teds a explicit ocking is being done atte or ahared-mode Jos q jusive (SIXI Mode cclusive explicit locking oe, Ite oa, shared and intent anette exci sine mete SSS tne de remo ok er GATE CRANURI OEE TTS TIPLE SEAMUDATT LOOMIS ST cen regimen lai Se Toby te fllwine hese ral a 1 Temust observe the lock-comt 2 mpc ne ot ote 2 nese ye Gns =e ay ss teste anode 91218 Se so ix ede
is associated. . ‘contains three data fit {me stamp before the tra ynsaction £oh version Or i content 2} ime star (On) 2 nesta (On) RECOVERY WITH CONCURRENT TRANSAGT ION 5 ra conden ee saved netion with Concurrency Coenen the various . ends greatly on the concur In this sct arava Ee sy cnttshee Ont tion Rebck in bis chene wera shee ii eS ras Tranter saa te of backward or rey (eahsacton yy an dow restores the da te 87 log record found be eee 4, Dueck points: this scheme we used check nthe log the ect Fate system must scan when It recovers froma veg .saction-processing system, we ascovers from al we require that the el ‘rast We alte oreecte eee (UPTV, 2008 the number nce og record be othe ictions active at the time of the ana epomnt E>, where Srcck pint che point sa checkpoint where tea Ae butler blocks are being written out. A ene Recovery When the system recover The unde ee redone, The aystem constructs the fee tranaaet uh emply. The system scans the log backward, ina it Binds the first
record, °& backward, lowed to perform updates iteonatrt sol thereat cama st flows Ia, mining each record, pxampLe 8.1, Show that the two-phase locking prot ett ni tae a ons suppose phe ing Ss oo ‘crdlibiity, 1a sae sacle Ty Tyo Ty Which obey 2FL and w Then there ei at enelanbe schedule ples a len 2 precedence py 1on-eliabe a eee prace such yes, Witham greta ee eae a snr iene precedence graph Ty» 7, — v7 ality assume the phos Fr re eck poh The Bo Re a ten ‘Then for the cycle we have en for all transactions. aan ] Oy
You might also like
Functional Dependency & Normalization: BY: Richa Jain
PDF
No ratings yet
Functional Dependency & Normalization: BY: Richa Jain
83 pages
9 Design Theory
PDF
No ratings yet
9 Design Theory
47 pages
Normalization
PDF
No ratings yet
Normalization
71 pages
Lecture 9 DB Normalization
PDF
No ratings yet
Lecture 9 DB Normalization
112 pages
4 Normalisation
PDF
No ratings yet
4 Normalisation
97 pages
6 Normalization
PDF
No ratings yet
6 Normalization
72 pages
Relational Database Design
PDF
No ratings yet
Relational Database Design
92 pages
Functional Dependencies & Normalization For Relational Dbs
PDF
No ratings yet
Functional Dependencies & Normalization For Relational Dbs
76 pages
Normalization
PDF
No ratings yet
Normalization
177 pages
CH 14 FDs and Normalization PDF
PDF
No ratings yet
CH 14 FDs and Normalization PDF
55 pages
Functional Dependencies and Normalization For Relational Databases
PDF
No ratings yet
Functional Dependencies and Normalization For Relational Databases
77 pages
MODULE 4 - Normalization - 1
PDF
No ratings yet
MODULE 4 - Normalization - 1
107 pages
Module 4 Dbms Student
PDF
No ratings yet
Module 4 Dbms Student
51 pages
Functional Dependencies and Normalization4
PDF
No ratings yet
Functional Dependencies and Normalization4
86 pages
Relational Database Design
PDF
No ratings yet
Relational Database Design
76 pages
Lecture 10: BCSE302L - DBMS: Functional Dependencies
PDF
No ratings yet
Lecture 10: BCSE302L - DBMS: Functional Dependencies
35 pages
01.functional Dependencies Till 5 NF
PDF
No ratings yet
01.functional Dependencies Till 5 NF
45 pages
Database Design Theory: Introduction To Databases CSCC43 Winter 2011 Ryan Johnson
PDF
No ratings yet
Database Design Theory: Introduction To Databases CSCC43 Winter 2011 Ryan Johnson
10 pages
St. Xavier'S College: Maitighar, Kathmandu
PDF
No ratings yet
St. Xavier'S College: Maitighar, Kathmandu
4 pages
FD
PDF
No ratings yet
FD
3 pages
Normalization
PDF
No ratings yet
Normalization
107 pages
Chapter 14
PDF
No ratings yet
Chapter 14
54 pages
Unit 4 Dbms
PDF
No ratings yet
Unit 4 Dbms
22 pages
21csc205p Dbms Unit IV
PDF
No ratings yet
21csc205p Dbms Unit IV
66 pages
DBMS Unit-5
PDF
No ratings yet
DBMS Unit-5
63 pages
MODULE4
PDF
No ratings yet
MODULE4
69 pages
Functional Dependencies: R&G Chapter 19
PDF
No ratings yet
Functional Dependencies: R&G Chapter 19
16 pages
Normalization
PDF
No ratings yet
Normalization
51 pages
Normal Is at Ion 1
PDF
100% (1)
Normal Is at Ion 1
30 pages
Functional Dependecy
PDF
No ratings yet
Functional Dependecy
47 pages
DBMS R19 - Unit-4
PDF
No ratings yet
DBMS R19 - Unit-4
9 pages
4 Normalization
PDF
No ratings yet
4 Normalization
41 pages
Functional Dependencies: CS 186, Spring 2006, Lecture 21 R&G Chapter 19
PDF
No ratings yet
Functional Dependencies: CS 186, Spring 2006, Lecture 21 R&G Chapter 19
17 pages
DBMS Module-2-Notes - Normalization
PDF
No ratings yet
DBMS Module-2-Notes - Normalization
18 pages
6 - Chapter 3 - Functional Dependencies
PDF
No ratings yet
6 - Chapter 3 - Functional Dependencies
29 pages
Dbms Unit-5 Notes
PDF
100% (2)
Dbms Unit-5 Notes
27 pages
Module No 5 Relational Database Design
PDF
No ratings yet
Module No 5 Relational Database Design
160 pages
Database Management Systems: Introduction To Schema Refinement
PDF
No ratings yet
Database Management Systems: Introduction To Schema Refinement
28 pages
IT 220 Unit 4 Relational-Database-Design
PDF
No ratings yet
IT 220 Unit 4 Relational-Database-Design
56 pages
Module No-5
PDF
No ratings yet
Module No-5
127 pages
DBMS Unit 3.0 Functional Dependencies
PDF
No ratings yet
DBMS Unit 3.0 Functional Dependencies
44 pages
Chapter 7
PDF
No ratings yet
Chapter 7
37 pages
Lecture 9 DB Normalization
PDF
No ratings yet
Lecture 9 DB Normalization
112 pages
DBMSPPTModule 4
PDF
No ratings yet
DBMSPPTModule 4
93 pages
DB Normalization Part1
PDF
No ratings yet
DB Normalization Part1
71 pages
ch4dbms FDand Nor
PDF
No ratings yet
ch4dbms FDand Nor
73 pages
Unit - Iv B
PDF
No ratings yet
Unit - Iv B
89 pages
2.3 1NF, 2NF, 3NF, 4NF, 5NF
PDF
No ratings yet
2.3 1NF, 2NF, 3NF, 4NF, 5NF
100 pages
DBMS 3
PDF
No ratings yet
DBMS 3
25 pages
FD and Closure Attribute
PDF
No ratings yet
FD and Closure Attribute
42 pages
DBMS Unit 3 Updated by Engineering Express
PDF
No ratings yet
DBMS Unit 3 Updated by Engineering Express
24 pages
MODULE 4 - Normalization - 1
PDF
No ratings yet
MODULE 4 - Normalization - 1
107 pages
Unit-3 Normalization in Data Base
PDF
No ratings yet
Unit-3 Normalization in Data Base
109 pages
En Database Principle-C6 Normalization Part1 TL
PDF
No ratings yet
En Database Principle-C6 Normalization Part1 TL
44 pages
UNIT IV Dbms
PDF
No ratings yet
UNIT IV Dbms
20 pages
Module-4 Schema Refinement
PDF
No ratings yet
Module-4 Schema Refinement
45 pages
DBMS NOTES (Database Design)
PDF
No ratings yet
DBMS NOTES (Database Design)
13 pages