functional dependencies er. dharmesh dubey. consider the fd set below: f={a->b, c->x,...

16
Functional Dependencies Er. Dharmesh Dubey

Upload: marian-morton

Post on 17-Dec-2015

214 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Functional Dependencies Er. Dharmesh Dubey. Consider the FD set below: F={A->B, C->X, BX->Z} Prove that AC->Z CB->Z AC->Z Proved (C->X and BX->Z, Pseudo

Functional Dependencies

Er. Dharmesh Dubey

Page 2: Functional Dependencies Er. Dharmesh Dubey. Consider the FD set below: F={A->B, C->X, BX->Z} Prove that AC->Z CB->Z AC->Z Proved (C->X and BX->Z, Pseudo

Consider the FD set below:F={A->B, C->X, BX->Z}Prove that AC->ZCB->ZAC->Z

Proved

(C->X and BX->Z, Pseudo Transitivity)(A->B and CB->Z, Pseudo Transitivity)

Page 3: Functional Dependencies Er. Dharmesh Dubey. Consider the FD set below: F={A->B, C->X, BX->Z} Prove that AC->Z CB->Z AC->Z Proved (C->X and BX->Z, Pseudo

Consider the FD set below:F={A->B, BC->D}Which two are the correct derivation from above FD set?A. AC->DB. B->DC. AD->BD. C->AB

Answer A:AC->D (Pseudo Transitivity)

Answer C:A->BAD->BD (Augmentation)AD->B (Decomposition)

Page 4: Functional Dependencies Er. Dharmesh Dubey. Consider the FD set below: F={A->B, C->X, BX->Z} Prove that AC->Z CB->Z AC->Z Proved (C->X and BX->Z, Pseudo

CLOSURE of FD set

Consider the FD set below for R(A,B,C,D)F={A->B, A->C, BC->D}, Find F+

A->BCA->DAB->D

F+={A->BC, A->D, AB->D}

(Union)(Transitivity)

(Pseudo Transitivity)

Page 5: Functional Dependencies Er. Dharmesh Dubey. Consider the FD set below: F={A->B, C->X, BX->Z} Prove that AC->Z CB->Z AC->Z Proved (C->X and BX->Z, Pseudo

Consider the FD set below for R(A,B,C,D, E, F)F={A->BC,B->E,CD->EF}, F+ are:A. {A->BC, A->D, AB->D}B. {A->C,AD->CD,AD->EF,AD->F}C. {AB-A,C->B,SD->EF}D. {A->C,AD->CD,AD->EF}

Answer B:A->BCA->B, A->CAD->CDAD->EF

Page 6: Functional Dependencies Er. Dharmesh Dubey. Consider the FD set below: F={A->B, C->X, BX->Z} Prove that AC->Z CB->Z AC->Z Proved (C->X and BX->Z, Pseudo

CLOSURE OF ATTRIBUTE

Consider the FD set below for R(A,B,C,D,E)F={AB->C,A->D,D->E,AC->B}, Find (AB)+

X={AB}AB->C X={ABC}A->D X={ABCD}D->E X={ABCDE}AC-> B is already in X(AB)+={ABCDE}

Page 7: Functional Dependencies Er. Dharmesh Dubey. Consider the FD set below: F={A->B, C->X, BX->Z} Prove that AC->Z CB->Z AC->Z Proved (C->X and BX->Z, Pseudo

Consider the FD set below for R(A,B,C,D,E,F)F={A->BC, E->CF, B->E, CD->EF}, the (AB)+ is:A. {ABCEF}B. {ABDEF}C. {ABCDF}D. {ACEF}

Answer: AX={AB} X={ABC} A->BCX={ABCE} B->E X={ABCEF} E->CF

Page 8: Functional Dependencies Er. Dharmesh Dubey. Consider the FD set below: F={A->B, C->X, BX->Z} Prove that AC->Z CB->Z AC->Z Proved (C->X and BX->Z, Pseudo

Membership

Consider R(A,B,C,D,E,F,H) and FD set below,F{A->B,BC->D,D->E,F->DE,DE->H}. Find whether

BC->H is the member of given FDs.X=BCX=BCD (BC->D)X=BCDE (D->E)X=BCDEH (DE->H)H is the subset of X, BC->H is a member of F

Page 9: Functional Dependencies Er. Dharmesh Dubey. Consider the FD set below: F={A->B, C->X, BX->Z} Prove that AC->Z CB->Z AC->Z Proved (C->X and BX->Z, Pseudo

Consider R(X,Y,Z,W) and FD set below,F={X->YW, XW->Z, Z->Y, XY->Z}. XY-> Z is the

member of F.

A. TRUEB. FALSE

Answer: AS=XYS=XYW (X->YW)S=XYWZ (XW->Z)Z is the subset of S, XY->Z is the member of F

Page 10: Functional Dependencies Er. Dharmesh Dubey. Consider the FD set below: F={A->B, C->X, BX->Z} Prove that AC->Z CB->Z AC->Z Proved (C->X and BX->Z, Pseudo

Nonredundant Cover/Minimal Cover

R(A,B,C,D) and F={A->B, B->C, BC->D, DA->B}Find minimal cover.A->B, {B->C, BC->D, DA->B}X={A}B->C, {A->B, BC->D, DA->B}X={B}BC->D, {A->B, B->C, DA->B}X={BC}DA->B, {A->B, B->C, BC->D}X={DA}X={DAB}(A->B)X={DABC} (B->C)

Minimal cover is {A->B, B->C, BC->D}

Page 11: Functional Dependencies Er. Dharmesh Dubey. Consider the FD set below: F={A->B, C->X, BX->Z} Prove that AC->Z CB->Z AC->Z Proved (C->X and BX->Z, Pseudo

R(A,B,C,D,E,H) and FD F={A->BC, CD->E, E->C, D->AEH, ABH->BD, DH->BC}, the minimal cover is:

A. {A->B, B->C, BC->D}B. {A->B,BC->D,D->E, DE->H}C. {A->BC, E->C, D->AEH, ABH->BD}D. {A->BC,B->E,CD->EH }

Answer: CA->BC, {CD->E, E->C, D->AEH, ABH->BD, DH->BC}X={A}CD->E, {A->BC, E->C, D->AEH, ABH->BD, DH->BC}X={CD}X={CDAEH}X={CDAEHB}E->C, {A->BC, CD->E, D->AEH, ABH->BD, DH->BC}X={E}D->AEH, A->BC, CD->E, E->C, ABH->BD, DH->BC}X={AEH}ABH->BD, {A->BC, CD->E, E->C, D->AEH, DH->BC}X={ABH}X={ABHC}DH->BC, {A->BC, CD->E, E->C, D->AEH, ABH->BD}X={DH}X={DHAE}X={DHAEBC}{A->BC, CD->E, E->C, D->AEH, ABH->BD}

Page 12: Functional Dependencies Er. Dharmesh Dubey. Consider the FD set below: F={A->B, C->X, BX->Z} Prove that AC->Z CB->Z AC->Z Proved (C->X and BX->Z, Pseudo

Canonical CoverR(A,B,C,D,E,F) and F={ABD->AC, C->BE, AD-BF,

B->E}, Find FcApply DecompositionH={ABD->A, ABD->C, C->B, C->E, AD->B, AD->F, B->E}ABD->A,{ABD->C, C->B, C->E, AD->B, AD->F, B->E}(ABD)+={ABDC}, contains A, so remove.H={ABD->C, C->B, C->E, AD->B, AD->F, B->E}ABD->C, {C->B, C->E, AD->B, AD->F, B->E}(ABD)+={ABDFE}, no C, so needed.C->B, {ABD->C, C->E, AD->B, AD->F, B->E}C+={CE}, no B, so neededC->E,{ABD->C, C->B, AD->B, AD->F, B->E}C+={CBE}, contains E, so removeH={ABD->C, C->B, AD->B, AD->F, B->E}Remove LHS attributeDrop AJ={BD->C, C->B, AD->B, AD->F, B->E}

(BD)+[H]={BDE}(BD)+[J]={BDEC}, different, don’t drop A.Drop BJ={AD->C,C->B,AD->F, B->E}(AD)+[H]={ADBFEC}(AD)+[J]={ADCBFE}, similar, so drop BH={AD->C, C->B, AD->B, AD->F, B->E}Drop DJ ={A->C, C->B, AD->B, AD->F, B->E}A+[H]={A}A+[J]={ACBE}, different, don’t drop DAD->B, ={AD->C, C->B,AD->F, B->E}(AD)+={ADCBFE}, contains B, so removeH={AD->C, C->B, AD->F, B->E}AD->F, {AD->C, C->B, AD->B, B->E}(AD)+={ADCBE}, no F, so needed.Fc={AD->C, C->B, AD->B, B->E}

Page 13: Functional Dependencies Er. Dharmesh Dubey. Consider the FD set below: F={A->B, C->X, BX->Z} Prove that AC->Z CB->Z AC->Z Proved (C->X and BX->Z, Pseudo

R(A,B,C) and F={A->BC, B->C, A->B, AB->C}, Fc is:

A. Fc= {A->B, B->C}

B. Fc= {A->BC, B->C}

C. Fc= {A->B, B->C,AC->B}

D. Fc={A->B, B->C,AB->C}

R(A,B,C) and F={A->BC, B->C, A->B, AB->C}, Find Fc

H={A->B, A->C, B->C, A->B, AB->C} (Singleton)

H={A->B, A->C, B->C,AB->C}A->B, {A->C, B->C,AB->C} A+={AC}, no B, so needed.A->C,{ A->B, B->C,AB->C}A+={ABC}, contains C,

remove.

H={A->B, B->C, AB->C}

B->C, {A->B, AB->C}B+={B}, no C, so needed

AB->C, {A->B, B->C}(AB)+={ABC}, contains C,

remove.

Fc= {A->B, B->C}

Page 14: Functional Dependencies Er. Dharmesh Dubey. Consider the FD set below: F={A->B, C->X, BX->Z} Prove that AC->Z CB->Z AC->Z Proved (C->X and BX->Z, Pseudo

R(A,B,C) and F={A->BC, B->C, A->B, AB->C}, Find Fc

H={A->B, A->C, B->C, A->B, AB->C} (Singleton)

H={A->B, A->C, B->C,AB->C}A->B, {A->C, B->C,AB->C} A+={AC}, no B, so needed.A->C,{ A->B, B->C,AB->C}A+={ABC}, contains C,

remove.

H={A->B, B->C, AB->C}

B->C, {A->B, AB->C}B+={B}, no C, so needed

AB->C, {A->B, B->C}(AB)+={ABC}, contains C,

remove.

Fc= {A->B, B->C}

Page 15: Functional Dependencies Er. Dharmesh Dubey. Consider the FD set below: F={A->B, C->X, BX->Z} Prove that AC->Z CB->Z AC->Z Proved (C->X and BX->Z, Pseudo

Candidate Key

R(A,B,C,D) AND F={AB->C, C->D, D->A}, List candidate keys, prime attributes and non prime attributes.

(AB)+={ABCD}, Candidate KeyC+={CDA}, Not a Candidate KeyD+={DA}, Not a Candidate KeyPrime Attributes: A,B,C,D.

Page 16: Functional Dependencies Er. Dharmesh Dubey. Consider the FD set below: F={A->B, C->X, BX->Z} Prove that AC->Z CB->Z AC->Z Proved (C->X and BX->Z, Pseudo

Consider R(A,B,C,D,E) and F={A->BC, CD->E,B->D, E->A}

Which of the following are the candidate keys for the above relation R ?

AECCDBAll are the candidate keys of R