Professional Documents
Culture Documents
1NF, 2NF, 3NF Database Normalization
1NF, 2NF, 3NF Database Normalization
com/)
DATABASE TECHNOLOGY
SEETHEINDEX
Normalization of Database
DatabaseNormalisationisatechniqueoforganizingthedatainthedatabase.Normalizationisasystematicapproachofdecomposingtablestoeliminate
dataredundancyandundesirablecharacteristicslikeInsertion,UpdateandDeletionAnamolies.Itisamultistepprocessthatputsdataintotabularformby
removingduplicateddatafromtherelationtables.
Normalizationisusedformainlytwopurpose,
Eliminatingreduntant(useless)data.
Ensuringdatadependenciesmakesensei.edataislogicallystored.
WithoutNormalization,itbecomesdifficulttohandleandupdatethedatabase,withoutfacingdataloss.Insertion,UpdationandDeletionAnamoliesarevery
frequentifDatabaseisnotNormalized.TounderstandtheseanomaliesletustakeanexampleofStudenttable.
UpdationAnamoly:Toupdateaddressofastudentwhooccurstwiceormorethantwiceinatable,wewillhavetoupdateS_Addresscolumninall
therows,elsedatawillbecomeinconsistent.
InsertionAnamoly:Supposeforanewadmission,wehaveaStudentid(S_id),nameandaddressofastudentbutifstudenthasnotoptedforany
subjectsyetthenwehavetoinsertNULLthere,leadingtoInsertionAnamoly.
DeletionAnamoly:If(S_id)401hasonlyonesubjectandtemporarilyhedropsit,whenwedeletethatrow,entirestudentrecordwillbedeletedalong
withit.
Normalization Rule
Normalizationrulearedividedintofollowingnormalform.
1.FirstNormalForm
2.SecondNormalForm
3.ThirdNormalForm
4.BCNF
ThePrimarykeyisusuallyasinglecolumn,butsometimesmorethanonecolumncanbecombinedtocreateasingleprimarykey.Forexampleconsidera
tablewhichisnotinFirstnormalform
StudentTable:
Adam 15 Biology,Maths
Alex 14 Maths
Stuart 17 Maths
InFirstNormalForm,anyrowmustnothaveacolumninwhichmorethanonevalueissaved,likeseparatedwithcommas.Ratherthanthat,wemust
separatesuchdataintomultiplerows.
StudentTablefollowing1NFwillbe:
Adam 15 Biology
Adam 15 Maths
Alex 14 Maths
Stuart 17 Maths
UsingtheFirstNormalForm,dataredundancyincreases,astherewillbemanycolumnswithsamedatainmultiplerowsbuteachrowasawholewillbe
unique.
AspertheSecondNormalFormtheremustnotbeanypartialdependencyofanycolumnonprimarykey.Itmeansthatforatablethathasconcatenated
primarykey,eachcolumninthetablethatisnotpartoftheprimarykeymustdependupontheentireconcatenatedkeyforitsexistence.Ifanycolumn
dependsonlyononepartoftheconcatenatedkey,thenthetablefailsSecondnormalform.
InexampleofFirstNormalFormtherearetworowsforAdam,toincludemultiplesubjectsthathehasoptedfor.Whilethisissearchable,andfollowsFirst
normalform,itisaninefficientuseofspace.AlsointheaboveTableinFirstNormalForm,whilethecandidatekeyis{Student,Subject},AgeofStudent
onlydependsonStudentcolumn,whichisincorrectasperSecondNormalForm.Toachievesecondnormalform,itwouldbehelpfultosplitoutthesubjects
intoanindependenttable,andmatchthemupusingthestudentnamesasforeignkeys.
NewStudentTablefollowing2NFwillbe:
Student Age
Adam 15
Alex 14
Stuart 17
InStudentTablethecandidatekeywillbeStudentcolumn,becauseallothercolumni.eAgeisdependentonit.
NewSubjectTableintroducedfor2NFwillbe:
Student Subject
Adam Biology
Adam Maths
Alex Maths
Stuart Maths
InSubjectTablethecandidatekeywillbe{Student,Subject}column.Now,boththeabovetablesqualifiesforSecondNormalFormandwillneversuffer
fromUpdateAnomalies.AlthoughthereareafewcomplexcasesinwhichtableinSecondNormalFormsuffersUpdateAnomalies,andtohandlethose
scenariosThirdNormalFormisthere.
ThirdNormalformappliesthateverynonprimeattributeoftablemustbedependentonprimarykey,orwecansaythat,thereshouldnotbethecasethat
anonprimeattributeisdeterminedbyanothernonprimeattribute.Sothistransitivefunctionaldependencyshouldberemovedfromthetableandalsothe
tablemustbeinSecondNormalform.Forexample,consideratablewithfollowingfields.
Student_DetailTable:
InthistableStudent_idisPrimarykey,butstreet,cityandstatedependsuponZip.Thedependencybetweenzipandotherfieldsiscalledtransitive
dependency.Hencetoapply3NF,weneedtomovethestreet,cityandstatetonewtable,withZipasprimarykey.
NewStudent_DetailTable:
AddressTable:
Theadvantageofremovingtranstivedependencyis,
Amountofdataduplicationisreduced.
Dataintegrityachieved.
BoyceandCoddNormalFormisahigherversionoftheThirdNormalform.Thisformdealswithcertaintypeofanamolythatisnothandledby3NF.A3NF
tablewhichdoesnothavemultipleoverlappingcandidatekeysissaidtobeinBCNF.ForatabletobeinBCNF,followingconditionsmustbesatisfied:
Rmustbein3rdNormalForm
and,foreachfunctionaldependency(X>Y),XshouldbeasuperKey.
Prev(databasekey.php) Next(erdiagram.php)