0% found this document useful (0 votes)
37 views5 pages

Functional Dependencies

The document discusses various concepts related to functional dependencies including: 1) It defines functional dependencies and provides examples of tables that satisfy and violate certain functional dependencies. 2) It describes the characteristics of trivial, non-trivial, and completely non-trivial functional dependencies. 3) It explains concepts like logical implication between sets of functional dependencies, closure of attributes, and equivalent functional dependencies. 4) It discusses keys, lossless decompositions, various normal forms like BCNF and 3NF, and algorithms for testing and decomposing schemas in normal form.

Uploaded by

Haha Mong
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views5 pages

Functional Dependencies

The document discusses various concepts related to functional dependencies including: 1) It defines functional dependencies and provides examples of tables that satisfy and violate certain functional dependencies. 2) It describes the characteristics of trivial, non-trivial, and completely non-trivial functional dependencies. 3) It explains concepts like logical implication between sets of functional dependencies, closure of attributes, and equivalent functional dependencies. 4) It discusses keys, lossless decompositions, various normal forms like BCNF and 3NF, and algorithms for testing and decomposing schemas in normal form.

Uploaded by

Haha Mong
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

NotesofFunctionalDependencies

FunctionalDependency(FD)
When ,ifvalueofaisofaspecificvalue,bmustbetheotherindicatedvalueandnotanother
value

Tablebelowshowsthat sinceifA=1,B=5.A=2,B=4.

A B
1 5
1 5
2 4
Tablebelowviolates sincewhenA=1,B=5&B=2.

A B
1 5
1 2
2 4

Trivial,Nontrivial,Completelynontrivial
Trivial, ,RHSissubsetofLHS

NonTrivial, ,LHSandRHSgotsomecommonattributes

CompletelyNonTrivial, ,LHSandRHStotallynolink

LogicallyImplies
ifeveryFDinFisinG

Whensaying ,isjustaskingif isinsideF.

Closure
ClosureofFmeanseverythingthatcanbelinkeddirectly&indirectlyfrom1attributetoanother

e.g. , , , , , , ,

Startwith1FDandcalculatetherest.

Calculationofclosureattributes
GivenR(a,b,c,d)R={ , ,

Tofindclosureofe.g.

1. Startwith
2. Lookthroughthedependenciesandseeifanyotherattributescanbederievedfromother
FDs
from ,
from ,
3. WhenthereisnomorechangeswhenloopingthroughtheFDs,thentheresultistheClosure
ofthatattribute
EquivalentFD
if ,alsocanuse

Axioms
Reflexivity:given(a,b,c) .Subset

Augmentation: , .Multiplybothsidesbyy

Transitivity: ,

Union: ,

Decomposition: , ,

KeysStuff
Superkey:AbunchofattributesthatcandetermineallattributesinR,usuallyhaveredundant
attributes.Nocombinationofthekeysmustbethesameintherelation

Key/Candidatekey:AbunchofattributesthatcandetermineallattributesofRANDnosubsetof
thatkeycanbeasuperkey(noredundantattributes)

Todeterminethekey,lookforattributesmissingintheRHSandstartfromthere.

Primeattribute:AnattributethatisinsomekeyofR

Minimal/CanonicalCover
MinimalnumberofFDsrequiredthatstillmapsbacktoFDsofF

Step1:DecomposeallRHStosingleattributes
Step2:Removalofredundantattributes
ForeachoftheFDs
ForeachattributeintheLHSofanFD
1. Findtheclosureofthat(FDremoved)attribute
a. iftheclosurecontainstheRHS,thentheattributeisredundant
b. elseitisnotnonredundant

Step3:RemovalofredundantFDs
ForeachoftheFDs(afterremovalofredundantattributes)
1. FindclosureofLHSusingFDw.r.t(FwiththatFDremoved)
a. IfclosurecontainsRHS,redundant.
b. Elsenotredundant

Resultsinaminimalcover

Checkingforlossless

Ifmultipletables,findouthowtheyaredecomposedandcheckforeachbreakdowniflosslessornot

Alternatemethod
Createatablewhere
columns=#ofattributes

rows=#ofdecompositions

e.g. , , ,

, ,

Startwith

A B C D E G
X X
X X
X X X X
X X

ForeachFD,ifwehave2rowswithXforLHS,andatleast1XontheRHS.FilluptheRHSofthose
rowswithoutX.

e.g.for . and hasXonB,but doesnotcontainD.SofillthatcolumnwithanX

A B C D E G
X X O
X X
X X X X
X X

Continuewiththerest(Repeatagainandagainuntilnomorecanbefilled)

A B C D E G
X X O O O
X X O
X X X X O
X X

IfthereisarowwithallX/O,thismeansdecompositionislossless,otherwiselossy(asinthis
example).Whatthisisdoingisjoiningthetablestoseeifwecangetbacktheoriginaldata)

LosslessJoinDecompositions
If isnontrivial.ThenthedecompositionofRinto , isalosslessjoindecomposition

If , , islosslessand , , , islosslessdecompositionof then


, , , , , , arelosslessdecompositionofR
ComputingFDProjections
ProjectionofabiggersetofFDtoasmallersetofFDs.ProjectionofFonaisthesetofFDsin that
involesonlyattributesina.

Calculating :

1. Startwithresultasemptyset
2. LoopthrougheachattributeofFincludingcombinationsofattributes(calledb)
a. Computetheclosureofb
b. RemovenonrelatedFDsofa,byintersectingwitha.ThusLHSclosure
c. Addthe(LHSclosure)totheresultset

Checkingifdependencyispreserved
and Trivialtoproof,mainaimistoprooffirstcondition

IfthereisanFDinFsuchthattheunionsdontcontainf,thenitisnotdependencypreserving.

DependencyPreservingDecompositions
1. Computeprojections foreachtable
2. Unionalltheprojections,calledG
3. LoopthrougheachFD, ,inF
a. Compute wrtG
b. if doesnotcontainb,thenno

BoyceCoddNormalForm(BCNF)
Assumptions:RHSisasingleattribute

NotallschemashasadependencypreservingBCNF

TobeBCNF:ForeverynontrivialFD( )ofF,ifaisnotasupeykey,violatesBCNF.OnlyifALL
FDsdontviolatethenitisBCNF.

**CanonlycheckagainstoriginalFDwhencheckingiftheoriginalschemaisinBCNF**

**Whencheckingdecomposedschema,checkwithEVERY **

e.g. , , , , , andthat ,

isnotBCNFsince isin and isACD,and violatesBCNF.

in iscomputedfrom ,

BCNFProperty(lemma2)
Anyschemathathas2attributesisBCNF

BCNFTest/DecomposingtoBCNF(Input:Fand ,returnsnull/FDthatviolatesBCNF)
1. If2attributes,returnnull(BCNFPropertylemma2)
2. Loopthrougheachain
a. let w.r.tF( isanFDthatholdson )
b. ifX=a,FDistrivial,tossaway
c. ifX= ,alphaissuperkey,doesnotviolateBCNF,tossaway
d. elsereturn (SuchaFDviolatesBCNF)
3. returnnull

Example
, , , , ,with ,

, , , , , using from

, , , , , , , using from

BCNFatthispoint

ThirdNormalForm(3NF)
Guaranteeslosslessjoinandpreservedependencies

3NF:ForeverynontrivialFD ,aisasuperkeyorbisaprimeattribute(appearinsomekey)

Violationof3NF:ForeverynontrivialFD ,aisnotsuperkeyandbisnonprimeattribute

3NFDecomposition/Synthesisalgorithm
GivenFmustbeaminimalcoverofR.Returns3NFdecomposition.

1. Startanemptysetforresult
2. ApplyunionruleforFDscalledG(GroupFDswithsameLHS,reduceno.oftablescreated)
3. ForeachFDinG( )
a. Createschema ,
b. Addthisschematoresult(Willresultin#FDtables)
4. Chooseakeykandcreateatablewiththoseattributes(formissingattributesinFD)
5. Removeredundanttablesinresult(e.g.ABC,ABCD,canremovetablewithABC,ifsuperset,
removesmallerone)
6. Returnresult

You might also like