Introduction
Normalization
Database Anomaly
Functional Dependency
Normal Forms
2
Database Normalization
Prof. K. Adisesha
Introduction
Prof. K. Adisesha (Ph. D)
3
DatabaseDesignStrategies:
Databasedesigncanbedefinedasacollectionoftasksorprocessesthat
enhancethedesigning,development,implementation,andmaintenanceof
enterprisedatamanagementsystem.
➢Designingaproperdatabasereducesthemaintenancecosttherebyimprovingdata
consistencyandthecost-effectivemeasuresaregreatlyinfluencedintermsofdisk
storagespace.
➢Therearetwoapproachesfordevelopinganydatabase:
❖Thetop-downmethod
❖Thebottom-upmethod
Introduction
Prof. K. Adisesha (Ph. D)
4
Top–downdesignmethod:
Thetop-downdesignmethodstartsfromthegeneralandmovestothe
specific.
➢Itstartwithageneralideaofwhatisneededforthesystemandthenworkyourway
downtothemorespecificdetailsofhowthesystemwillinteract.
➢Thisprocessinvolvestheidentificationofdifferent
entitytypesandthedefinitionofeachentity’s
attributes.
Introduction
Prof. K. Adisesha (Ph. D)
5
Bottom–updesignmethod:
Thebottom-upapproachbeginswiththespecificdetailsandmovesupto
thegeneral.
➢Thisisdonebyfirstidentifyingthedataelements(items)andthengroupingthem
togetherindatasets.
➢Inotherwords,thismethodfirstidentifiestheattributes,andthengroupsthemtoform
entities.
Introduction
Prof. K. Adisesha (Ph. D)
6
Normalizationistheprocessoforganizingthedataandtheattributesofa
database.
➢Itisperformedtoreducethedataredundancyinadatabaseandtoensure
thatdataisstoredlogically.
➢Dataredundancymeanshavingthesamedatabutatmultipleplaces.
➢Itisnecessarytoremovedataredundancybecauseitcausesanomaliesin
adatabasewhichmakesitveryhardforadatabaseadministratorto
maintainit.
Introduction
Prof. K. Adisesha (Ph. D)
7
Normalization:
Normalizationisastepbystepprocessofremovingthedifferentkindsofredundancy
andanomalyonestepatatimefromthedatabase.
➢E.FCodddevelopedfortherelationdatamodelin1970.
➢Normalizationrulesaredividedintofollowingnormalform:
Normalization
Prof. K. Adisesha (Ph. D)
8
Normalizationistheprocessoforganizingthedataandtheattributesofa
database.Themainreasonfornormalizingtherelationsisremovingthese
anomalies.
➢Normalizationistheprocessoforganizingthedatainthedatabase.
➢Normalizationisusedtominimizetheredundancyfromarelationorsetofrelations.It
isalsousedtoeliminateundesirablecharacteristicslikeInsertion,Update,and
DeletionAnomalies.
➢Normalizationdividesthelargertableintosmallerandlinksthemusingrelationships.
➢Thenormalformisusedtoreduceredundancyfromthedatabasetable.
Normalization
Prof. K. Adisesha (Ph. D)
9
Themainreasonfornormalizingtherelationsisremovingthese
anomalies.
➢AdvantagesofNormalization
❖Normalizationhelpstominimizedataredundancy.
❖Greateroveralldatabaseorganization.
❖Dataconsistencywithinthedatabase.
❖Muchmoreflexibledatabasedesign.
❖Enforcestheconceptofrelationalintegrity.
➢DisadvantagesofNormalization
❖Itisverytime-consuminganddifficulttonormalizerelationsofahigherdegree.
❖Carelessdecompositionmayleadtoabaddatabasedesign,leadingtoseriousproblems.
Normalization
Prof. K. Adisesha (Ph. D)
10
Need for Normalization:
Normalizationisusedtoreducedataredundancy.Itprovidesamethodtoremovethe
followinganomaliesfromthedatabaseandbringittoamoreconsistentstate:
➢Adatabaseanomalyisaflawinthedatabasethatoccursbecauseofpoorplanningand
redundancy.
❖Insertionanomalies:Thisoccurswhenwearenotabletoinsertdataintoadatabase
becausesomeattributesmaybemissingatthetimeofinsertion.
❖Updationanomalies:Thisoccurswhenthesamedataitemsarerepeatedwiththe
samevaluesandarenotlinkedtoeachother.
❖Deletionanomalies:Thisoccurswhendeletingonepartofthedatadeletestheother
necessaryinformationfromthedatabase.
Normalization
Prof. K. Adisesha (Ph. D)
11
DatabaseNormalForms.
TheTheoryofDataNormalizationinMySQLserverisstillbeingdevelopedfurther,
therearediscussionsevenon6thNormalForm.
➢However,inmostpracticalapplications,normalizationachievesitsbestin3rdNormal
Form.TheevolutionofNormalizationinSQLtheoriesisillustratedbelow-
❖1NF(FirstNormalForm)
❖2NF(SecondNormalForm)
❖3NF(ThirdNormalForm)
❖BCNF(Boyce-CoddNormalForm)
❖4NF(FourthNormalForm)
❖5NF(FifthNormalForm)
❖6NF(SixthNormalForm)
Normalization
Prof. K. Adisesha (Ph. D)
12
DatabaseNormalForms.
Tounderstandtheabove-mentionednormalforms,wefirstneedtohavean
understandingofthefunctionaldependencies.
➢Therearefourtypesofnormalformsthatareusuallyusedinrelationaldatabases
❖1NF:Arelationisin1NFifallitsattributeshaveanatomicvalue.
❖2NF:Arelationisin2NFifitisin1NFandallnon-keyattributesarefully
functionaldependentonthecandidatekey.
❖3NF:Arelationisin3NFifitisin2NFandthereisnotransitivedependency.
❖BCNF:ArelationisinBCNFifitisin3NFandforeveryFunctionalDependency,
LHSisthesuperkey.
Functional dependency
Prof. K. Adisesha (Ph. D)
13
Functionaldependency.
Thefunctionaldependencyisarelationshipthatexistsbetweentwoattributes.It
typicallyexistsbetweentheprimarykeyandnon-keyattributewithinatable.
➢TheleftsideofFDisknownasadeterminant,therightsideoftheproductionisknown
asadependent.
➢ItisdenotedbyX->Y,whereXiscalledadeterminantandYiscalleddependent.
➢Example:
❖Assumewehaveanemployeetablewithattributes:Emp_Id,Emp_Name,Emp_Address.
❖Functionaldependencycanbewrittenas:Emp_Id→Emp_Name
❖WecansaythatEmp_NameisfunctionallydependentonEmp_Id.
❖HereEmp_IdattributecanuniquelyidentifytheEmp_Nameattributeofemployeetable
becauseifweknowtheEmp_Id,wecantellthatemployeenameassociatedwithit.
Functional dependency
Prof. K. Adisesha (Ph. D)
14
Functionaldependency.
Thefunctionaldependencyisarelationshipthatexistsbetweentwoattributes.It
typicallyexistsbetweentheprimarykeyandnon-keyattributewithinatable.
➢TypesofFunctionaldependency
❖Trivialfunctionaldependency
❖Non-Trivialfunctionaldependency
❖Multivaluedfunctionaldependency
❖Transitivefunctionaldependency.
roll_noname age
42 abc 17
43 pqr 18
44 xyz 18
➢Here, {roll_no, name} → name is a trivial functional dependency, since the dependent name is a subset of determinant
set {roll_no, name}
➢roll_no→ name is a non-trivial functional dependency, since the dependent name is not a subset of determinant roll_no.
➢If a → {b, c} and there exists no functional dependency between b and c, then it is called a multivalued functional
dependency.
➢If a → b & b → c, then according to axiom of transitivity, a → c. This is a transitive
Normal Form :
Prof. K. Adisesha (Ph. D)
18
SecondNormalForm(2NF):
2NF:ThefirstconditionforthetabletobeinSecondNormalFormisthatthetablehasto
beinFirstNormalForm.Thetableshouldnotpossesspartialdependency.
➢Inthe2NF,relationalmustbein1NF.
➢Inthesecondnormalform,allnon-keyattributesarefullyfunctionaldependentonthe
primarykey
S_IDS_NAME C_ID
101 SUNNY C01
102 SHAILU C01
103 PRAJWAL CO2
S_IDS_NAME S_COURSE
101 SUNNY BCA
102 SHAILU BCA
103 PRAJWAL BBA
C_IDS_COURSE
C01 BCA
C01 BCA
CO2 BBA
Normal Form :
Prof. K. Adisesha (Ph. D)
19
ThirdNormalForm(3NF):
3NF:ThethirdNormalFormensuresthereductionofdataduplication.Itisalsousedto
achievedataintegrity.
➢ThethirdNormalFormensuresthereductionofdataduplication.Itisalsousedto
achievedataintegrity.
➢Arelationwillbein3NFifitisin2NFandnotcontainanytransitivepartialdependency.
➢3NFisusedtoreducethedataduplication.Itisalsousedtoachievethedataintegrity.
Normal Form :
Prof. K. Adisesha (Ph. D)
20
ThirdNormalForm(3NF):
3NF:Arelationisin3NFifitisin2NFandthereisnotransitivedependency.
➢ThethirdNormalFormensuresthereductionofdataduplication.Itisalsousedto
achievedataintegrity.
➢Inthestudenttable,stu_iddeterminessubid,andsubiddeterminessub.Therefore,stu_id
determinessubviasubid.Thisimpliesthatthetablepossessesatransitivefunctional
dependency,anditdoesnotfulfillthethirdnormalformcriteria..
Normal Form
Prof. K. Adisesha (Ph. D)
21
BoyceCoddnormalform(BCNF):
BCNF:ArelationisinBCNFifitisin3NFandforeveryFunctionalDependency,LHSis
thesuperkey.
➢BCNFistheadvanceversionof3NF.Itisstricterthan3NF.
➢AtableisinBCNFifeveryfunctionaldependencyX→Y,Xisthesuperkeyofthetable.
➢ForBCNF,thetableshouldbein3NF,andforeveryFD,LHSissuperkey.
➢TotransformthetableintotheBCNF,youwilldividethetableintotwoparts.Onetablewillhold
stuidwhichalreadyexistsandthesecondtablewillholdanewlycreatedcolumnprofid.
STU_ID COURSE HOBBY
21 Computer Dancing
21 Math Singing
34 Chemistry Dancing
74 Biology Cricket
Normal Form
Prof. K. Adisesha (Ph. D)
22
Fourthnormalform(4NF):
4NF:Arelationwillbein4NFifitisinBoyceCoddnormalformandhasnomulti-valued
dependency.
➢ForadependencyA→B,ifforasinglevalueofA,multiplevaluesofBexists,thentherelation
willbeamulti-valueddependency.
➢ThegivenSTUDENTtableisin3NF,buttheCOURSEandHOBBYaretwoindependententity.Hence,
thereisnorelationshipbetweenCOURSEandHOBBY.
➢SotomaketheStudenttableinto4NF,wecandecomposeitintotwotablesCourse&Hobbytables:
STU_ID COURSE
21 Computer
21 Math
34 Chemistry
74 Biology
STU_ID HOBBY
21 Dancing
21 Singing
34 Dancing
74 Cricket
Normal Form
Prof. K. Adisesha (Ph. D)
23
Fifthnormalform(5NF):
4NF:Arelationisin5NFifitisin4NFandnotcontainsanyjoindependencyandjoining
shouldbelossless.
➢5NFissatisfiedwhenallthetablesarebrokenintoasmanytablesaspossibleinordertoavoid
redundancy.
➢5NFisalsoknownasProject-joinnormalform(PJ/NF).
➢SotomaketheSPCtableinto4NF,wecandecomposeitintothreetablesSP,SC&PCtables:
Normal Form
Prof. K. Adisesha (Ph. D)
24
Normalization:
Normalizationisastepbystepprocessofremovingthedifferentkindsofredundancy
andanomalyonestepatatimefromthedatabase.
Discussion
Prof. K. Adisesha (Ph. D)
25
Queries ?
Prof. K. Adisesha
9449081542