אביב-תשס"ז236363 - DBMS, Design1 צורה נורמלית – BCNF Boyce-Codd Normal Form מוטיבציה: תלות פונקציונלית בקבוצת אטריביוטים שאיננה מהווה על-מפתח יוצרת כפילויות

  • View
    222

  • Download
    3

Embed Size (px)

Text of אביב-תשס"ז236363 - DBMS, Design1 צורה נורמלית – BCNF Boyce-Codd Normal Form...

  • Slide 1
  • -"236363 - DBMS, Design1 BCNF Boyce-Codd Normal Form : - . : R , F R. R -BCNF F X Y -F +, X - R. -, .
  • Slide 2
  • -"236363 - DBMS, Design2 -BCNF? : F + X Y F + X -. : F + R. : R,F -BCNF, X Y F + -BCNF, Z W F -BCNF. , R(Cust_Id, Cust_Name,Room_Num) F={Cust_Id Cust_Name, Cust_IdRoom_Num, Room_NumCust_Id } -F R,F -BCNF.
  • Slide 3
  • -"236363 - DBMS, Design3 BCNF : F={ Cust_Id Track,Track Faculty } (Cust_Id, Track, Faculty, Book_Name)R -BCNF: -F Faculty Track, Track -. : R,F -BCNF. : , CS , CS. : -BCNF - R - -BCNF ( ).
  • Slide 4
  • -"236363 - DBMS, Design4 : R . R = {R 1, ,R n } - i n =1 R i = R . : ( ). - , F ( ).
  • Slide 5
  • -"236363 - DBMS, Design5 : , " -. , - , . -, .
  • Slide 6
  • -"236363 - DBMS, Design6 : R , F , = {R 1, ,R n } R. F r R r F : i n = 1 R i (r) = r : R(ID, NAME, ADDR), F = {ID NAME, ID ADDR} = {R 1 (ID, NAME), R 2 (NAME, ADDR)} . R :
  • Slide 7
  • -"236363 - DBMS, Design7 , = {R 1 (ID, NAME), R 2 (ID, ADDR)} : R 1 (r) R 2 (r) = r ADDRNAMEID "1 2 ADDRNAME " NAMEID 1 2 ADDRNAMEID "1 1 "2 2 r = R 1 (r) R 2 (r) R 1 (r) R 2 (r)
  • Slide 8
  • -"236363 - DBMS, Design8 : = {R 1, R 2 } F (R 1 R 2 ) (R 1 \ R 2 ) F (R 1 R 2 ) (R 2 \ R 1 ) ( R(ID, NAME, ADDR)): = {R 1 (ID, NAME), R 2 (NAME, ADDR)} NAME ID, NAME ADDR, R. , = {R 1 (ID, NAME), R 2 (ID, ADDR)} () ID NAME , , .
  • Slide 9
  • -"236363 - DBMS, Design9 -BCNF : R , F R, = {R 1,, R n } R. -BCNF - R i -BCNF R i F. : R , F R, S R. F - S (: s F) : s F = {X Y | X Y F + X Y S} F + F.
  • Slide 10
  • -"236363 - DBMS, Design10 -BCNF - : -BCNF . -BCNF - - -. , R X Y, R - : {R 1 [X Y],R 2 [R\(Y\X)]}. , . -BCNF. : ( -), .
  • Slide 11
  • -"236363 - DBMS, Design11 -BCNF - F : 1. {R} . 2. - -BCNF . 3. S -BCNF, X Y s F -X Y S, Y X - X - S. : ( \ {S}) {S\(Y\X)} {X Y} 5. -3.
  • Slide 12
  • -"236363 - DBMS, Design12 s F s F F +. s F : F + F s for each XYF such that XS do Z (X + F S)\X if Z then F s F s {X Z} Return F s : s F, ( ).
  • Slide 13
  • -"236363 - DBMS, Design13 -BCNF - : R ( ), F: R(snumber, sname, cnumber, cname, grade) F = {snumber sname, cnumber cname, (snumber, cnumber) grade} Snumber -- ' Sname -- Cnumber -- ' Cname -- Grade --
  • Slide 14
  • -"236363 - DBMS, Design14 - R(snumber, sname, cnumber, cname, grade) R 2 (snumber, cnumber, cname, grade) R 4 (cnumber, cname)R 3 (snumber, cnumber, grade) R 1 (snumber, sname) snumber sname cnumber cname : F = {snumber sname, cnumber cname, (snumber, cnumber) grade} , - {R 1,R 3,R 4 } - BCNF.
  • Slide 15
  • -"236363 - DBMS, Design15 -BCNF (1) R -BCNF " - R i -BCNF R i F ( F + ). R i -BCNF -F -R i. R i F " R i F -BCNF .
  • Slide 16
  • -"236363 - DBMS, Design16 -BCNF (2) : R=(A,B,C,D), C, C D} F={B, = {(A,B,D), (B,C)} : -BCNF. : R 1 BCNF D R 1 F B B - R 1 : R 1 -F -R 1 ( ), R 1 BCNF ( ). .
  • Slide 17
  • -"236363 - DBMS, Design17 (' - ): 1. r R. - R i r t i t i a A R i b i B R i. 2. -r , -r t i, t j - t i [X]=t j [X] (X Y) F, -t j [Y] -t i [Y], : A Y, t i [A], t j [A] a ( ), -a, t j [A] -t i [A] t i [A] -t j [A], . 3. -r .
  • Slide 18
  • Slide 19
  • -"236363 - DBMS, Design19 - t 2 , . FEDCBA f1f1 e1e1 d1d1 c1c1 ba f2f2 e2e2 dcb2b2 a fed3d3 c3c3 ba3a3 t1t1 t2t2 t3t3 A B (t 1,t 2 ) B EF (t 3,t 2 ) FEDCBA f1f1 e1e1 d1d1 c1c1 ba f2f2 e2e2 dcba fed3d3 c3c3 ba3a3 t1t1 t2t2 t3t3 FEDCBA f1f1 e1e1 d1d1 c1c1 ba fedcba fed3d3 c3c3 ba3a3 t1t1 t2t2 t3t3 1 2
  • Slide 20
  • Slide 21
  • -"236363 - DBMS, Design21 : - r i ( R i ) R i F F. : - , (- join - ) . , . , .
  • Slide 22
  • -"236363 - DBMS, Design22 : (, , )R { (, ), } =F , . , . : {(, )R 2, (, )R 1 }= : R1 R2 = , R2 \ R1 = , F : ?
  • Slide 23
  • -"236363 - DBMS, Design23 - , : r 1, r 2 F. 1234 1234 04 04 r1=r1=r2=r2=
  • Slide 24
  • -"236363 - DBMS, Design24 - -join F : - r 1 - r 2 . - . 041234 041234
  • Slide 25
  • -"236363 - DBMS, Design25 : R , F R, = {R 1,,R n }. (dependency preserving) F {r 1,,r n } ( {R 1,,R n } ) -r i Ri F i = 1,,n n i=1 r i F. : F F ( n i =1 Ri F) + : f - - f, f .
  • Slide 26
  • -"236363 - DBMS, Design26 R, F = {R 1, ,R n }, : For each f = ( X f Y f ) in F do Z f X f Repeat For i = 1 to n do Z f Z f ((Z f R i ) + F R i ) Until no more changes to Z f is dependency-preserving iff Y f Z f for every f in F. : X f Y f, "" X f, , Y f .
  • Slide 27
  • Slide 28
  • Slide 29
  • -"236363 - DBMS, Design29 BCNF : R,F -BCNF. : (, , )R {(,), }=F BCNF, . : (,) .
  • Slide 30
  • -"236363 - DBMS, Design30 BCNF BCNF. : : ( ) -BCNF ( ): (, )R2,(, )R1. / (, ' ) ( ): (, , )R : 3NF
  • Slide 31
  • -"236363 - DBMS, Design31 - 3NF : R F R. R -3NF F X A F + -X - -A R,F. : F . R,F -3NF, X A F + -3NF, Y B F -3NF.
  • Slide 32
  • -"236363 - DBMS, Design32 -3NF? : F , F' - F'= { X A | X Y F A Y} X A F X - -A R,F. -F 3NF, R,F -3NF. : R,F -3NF R,F - 3NF?
  • Slide 33
  • -"236363 - DBMS, Design33 (, , ) R : F = { , (, ) } -.3NF : (, ) - (,). F -3NF. F.
  • Slide 34
  • -"236363 - DBMS, Design34 3NF BCNF 3NF -BCNF: -BCNF -3NF, . BCNF 3NF. -3NF -BCNF. 3NF BCNF - - 3NF .
  • Slide 35
  • -"236363 - DBMS, Design35 R -3NF F: 1. -F -R, {R} - . 2. X A n X A 2,, X A 1, X, } X { A 1 A 2...A n. 3. R, R. .
  • Slide 36
  • -"236363 - DBMS, Design36 -3NF : : R(dname, daddr, id, pname, paddr, pres_no, date, med_name, qnt) F = { dname daddr, id pname, id paddr, id dname, pres_no date, pres_no id, (pres_no, med_name) qnt} 1. -F -R. 2. : R 1 (dname, daddr) R 2 (id, pname, paddr, dname) R 3 (pres_no, date, id) R 4 (pres_no, med_name, qnt) 3. R4 (pres_no, med_name), .