You are on page 1of 2

(http://www.studytonight.

com/)
ONLINECOURSES(http://studytonight.com/onlinecourses/)

STUDYROOM(http://studytonight.com/studyroom/)

WRITE
FORUS&
GETPAID!
(/collaborate)

LIBRARY(http://studytonight.com/library/)

DATABASEMANAGEMENTSYSTEM
FLASHCARDS(http://studytonight.com/flashcards/)

"WithoutSQL,websiteswillneverhaveanywaytohandleDatabasesfordata."

(http://www.addthis.com/bookmark.php?v=300&winname=addthis&pub=

TESTS NEW(http://studytonight.com/tests/)

us&s=linkedin&url=http%3A%2F%2Fwww.studytonight.com%2Fdbms%2F

normalization.php&title=1NF%2C%202NF%2C%203NF%20and%20BCNF
Like

4fcb15e01d1a671c//per

9.5k

13/54f3ebb017faa3b7/2&frommenu=1&uid=54f3ebb0c8c343b7&ct=1&pre=
Search

LogIn(http://www.studytonight.com/login)

SignUp(http://www.studytonight.com/register)

key.php&tt=0&captcha_provider=nucaptcha)

Suggest(http://www.studytonight.com/suggest)

Like

564

2K

NormalizationofDatabase
DatabaseNormalisationisatechniqueoforganizingthedatainthedatabase.Normalizationisasystematic

DatabaseConcept

approachofdecomposingtablestoeliminatedataredundancyandundesirablecharacteristicslikeInsertion,

OverviewofDBMS

UpdateandDeletionAnamolies.Itisamultistepprocessthatputsdataintotabularformbyremoving

(overviewofdbms)

duplicateddatafromtherelationtables.

DatabaseArchitecture

Normalizationisusedformainlytwopurpose,

(architectureofdatabase)
DatabaseModel(database

Eliminatingreduntant(useless)data.

model)

Ensuringdatadependenciesmakesensei.edataislogicallystored.

Codd'srule(coddrule)
RDBMSConcept(rdbms
concept)
Databasekey(database
key)
Normalization(database
normalization)
ERDiagrams(erdiagram)

ProblemWithoutNormalization
WithoutNormalization,itbecomesdifficulttohandleandupdatethedatabase,withoutfacingdataloss.
Insertion,UpdationandDeletionAnamoliesareveryfrequentifDatabaseisnotNormalized.Tounderstand
theseanomaliesletustakeanexampleofStudenttable.
S_id

S_Name

S_Address

Subject_opted

Specialization

401

Adam

Noida

Bio

(generalizationand

402

Alex

Panipat

Maths

403

Stuart

Jammu

Maths

404

Adam

Noida

Physics

Generalizationand

specialization)
SQLConcept
SQLIntroduction
(introductiontosql)
DDLCommand
Createquery(createquery)
Alterquery(alterquery)
Truncate,Dropand
Renamequery(truncate

UpdationAnamoly:Toupdateaddressofastudentwhooccurstwiceormorethantwiceinatable,we
willhavetoupdateS_Addresscolumninalltherows,elsedatawillbecomeinconsistent.
InsertionAnamoly:Supposeforanewadmission,wehaveaStudentid(S_id),nameandaddressofa

droprenamequery)

studentbutifstudenthasnotoptedforanysubjectsyetthenwehavetoinsertNULLthere,leadingto

DMLCommand

InsertionAnamoly.

AllDMLcommand(dml

DeletionAnamoly:If(S_id)401hasonlyonesubjectandtemporarilyhedropsit,whenwedeletethat

command)

row,entirestudentrecordwillbedeletedalongwithit.

TCLCommand
AllTCLCommand(tcl
command)
DCLCommand
AllDCLCommand(dcl
command)
WHEREclause(where
clause)
SELECTquery(select
query)

NormalizationRule
Normalizationrulearedividedintofollowingnormalform.
1. FirstNormalForm
2. SecondNormalForm
3. ThirdNormalForm
4. BCNF

LIKEclause(likeclause)
ORDERBYclause(orderby
clause)
GroupBYclause(groupby
clause)
Havingclause(having
clause)

FirstNormalForm(1NF)
AsperFirstNormalForm,notwoRowsofdatamustcontainrepeatinggroupofinformationi.eeachsetof
columnmusthaveauniquevalue,suchthatmultiplecolumnscannotbeusedtofetchthesamerow.Each
tableshouldbeorganizedintorows,andeachrowshouldhaveaprimarykeythatdistinguishesitasunique.

DISTINCTkeyword(distinct

ThePrimarykeyisusuallyasinglecolumn,butsometimesmorethanonecolumncanbecombinedtocreate

keyword)

asingleprimarykey.ForexampleconsideratablewhichisnotinFirstnormalform

AND&ORoperator(sql

StudentTable:

andoroperator)
AdvanceSQL
SQLConstraints(sql

Student

Age

Subject

Adam

15

Biology,Maths

Alex

14

Maths

Stuart

17

Maths

constraints)
SQLfunction(sqlfunction)
SQLJoin(joininginsql)
SQLAlias(sqlalias)
SQLSEToperation(set
operationinsql)
SQLSequences(sql
sequences)
SQLViews(sqlviews)

InFirstNormalForm,anyrowmustnothaveacolumninwhichmorethanonevalueissaved,likeseparated
withcommas.Ratherthanthat,wemustseparatesuchdataintomultiplerows.
StudentTablefollowing1NFwillbe:
Student

Age

Subject

Adam

15

Biology

TestYourself!

Adam

15

Maths

Ifyouhavestudiedallthelessons

Alex

14

Maths

Stuart

17

Maths

ofDBMS,thenevaluateyourselfby
takingthesetests.

DBMSTopicalTest(http://www.studytonight.com/dbms/tests/)
UsingtheFirstNormalForm,dataredundancyincreases,astherewillbemanycolumnswithsamedatain
multiplerowsbuteachrowasawholewillbeunique.

SecondNormalForm(2NF)
AspertheSecondNormalFormtheremustnotbeanypartialdependencyofanycolumnonprimarykey.It
meansthatforatablethathasconcatenatedprimarykey,eachcolumninthetablethatisnotpartofthe
primarykeymustdependupontheentireconcatenatedkeyforitsexistence.Ifanycolumndependsonlyon
onepartoftheconcatenatedkey,thenthetablefailsSecondnormalform.

InexampleofFirstNormalFormtherearetworowsforAdam,toincludemultiplesubjectsthathehasopted
for.Whilethisissearchable,andfollowsFirstnormalform,itisaninefficientuseofspace.Alsointheabove
TableinFirstNormalForm,whilethecandidatekeyis{Student,Subject},AgeofStudentonlydependson
Studentcolumn,whichisincorrectasperSecondNormalForm.Toachievesecondnormalform,itwouldbe
helpfultosplitoutthesubjectsintoanindependenttable,andmatchthemupusingthestudentnamesas
foreignkeys.
NewStudentTablefollowing2NFwillbe:
Student

Age

Adam

15

Alex

14

Stuart

17

InStudentTablethecandidatekeywillbeStudentcolumn,becauseallothercolumni.eAgeisdependenton
it.
NewSubjectTableintroducedfor2NFwillbe:
Student

Subject

Adam

Biology

Adam

Maths

Alex

Maths

Stuart

Maths

InSubjectTablethecandidatekeywillbe{Student,Subject}column.Now,boththeabovetablesqualifiesfor
SecondNormalFormandwillneversufferfromUpdateAnomalies.Althoughthereareafewcomplexcasesin
whichtableinSecondNormalFormsuffersUpdateAnomalies,andtohandlethosescenariosThirdNormal
Formisthere.

ThirdNormalForm(3NF)
ThirdNormalformappliesthateverynonprimeattributeoftablemustbedependentonprimarykey.The
transitivefunctionaldependencyshouldberemovedfromthetable.ThetablemustbeinSecondNormal
form.Forexample,consideratablewithfollowingfields.
Student_DetailTable:
Student_id

Student_name

DOB

Street

city

State

Zip

InthistableStudent_idisPrimarykey,butstreet,cityandstatedependsuponZip.Thedependencybetween
zipandotherfieldsiscalledtransitivedependency.Hencetoapply3NF,weneedtomovethestreet,city
andstatetonewtable,withZipasprimarykey.
NewStudent_DetailTable:
Student_id

Student_name

DOB

Zip

AddressTable:
Zip

Street

city

state

Theadvantageofremovingtranstivedependencyis,
Amountofdataduplicationisreduced.
Dataintegrityachieved.

BoyceandCoddNormalForm(BCNF)
BoyceandCoddNormalFormisahigherversionoftheThirdNormalform.Thisformdealswithcertaintype
ofanamolythatisnothandledby3NF.A3NFtablewhichdoesnothavemultipleoverlappingcandidatekeys
issaidtobeinBCNF.

Prev(databasekey.php)

Next(erdiagram.php)

CheckOut: Library (http://www.studytonight.com/library) VideoCourses (http://www.studytonight.com/onlinecourses) Studyroom


(http://www.studytonight.com/studyroom) Flashcards (http://www.studytonight.com/flashcards)
Studytonight2014

HandcraftedwithLove

AboutUs(http://www.studytonight.com/about)Suggest(http://www.studytonight.com/suggest)Terms(http://www.studytonight.com/terms)ContactUs
(http://www.studytonight.com/contact)Collaborate(http://www.studytonight.com/collaborate/)Authors(http://www.studytonight.com/authors/)Blog
(http://studytonight.tumblr.com/)

You might also like