1st, 2nd, and 3rd Normal FormsOverviewDatabase NormalizationData AnomaliesBrief History/Overview1st Normal Form The Requirements1st Normal Form Example2nd Normal Form The Requirements2nd Normal Form Example3rd Normal Form The Requirements3rd Normal Form Example3rd Normal Form Example Cont.ConclusionReferences11stst, 2, 2ndnd, and 3, and 3rdrd Normal FormsNormal FormsBy By Carlos AlvaradoCarlos AlvaradoSan Jose State UniversitySan Jose State UniversityOverviewOverviewToday we’ll talk about:Today we’ll talk about:Database NormalizationDatabase NormalizationData Anomalies Caused by:Data Anomalies Caused by:Update, Insertion, DeletionUpdate, Insertion, DeletionBrief History/OverviewBrief History/Overview11st st Normal FormNormal Form22nd nd Normal FormNormal Form33rdrd Normal Form Normal FormConclusionConclusionDatabase NormalizationDatabase NormalizationThe main goal of Database The main goal of Database Normalization is to restructure the Normalization is to restructure the logical data model of a database to:logical data model of a database to:Eliminate redundancyEliminate redundancyOrganize data efficiently Organize data efficiently Reduce the potential for data Reduce the potential for data anomalies.anomalies.Data AnomaliesData AnomaliesData anomalies are inconsistencies in the Data anomalies are inconsistencies in the data stored in a database as a result of an data stored in a database as a result of an operation such as update, insertion, and/or operation such as update, insertion, and/or deletion.deletion.Such inconsistencies may arise when have a Such inconsistencies may arise when have a particular record stored in multiple locations particular record stored in multiple locations and not all of the copies are updated.and not all of the copies are updated.We can prevent such anomalies by We can prevent such anomalies by implementing 7 different level of implementing 7 different level of normalization called Normal Forms (NF)normalization called Normal Forms (NF)We’ll only look at the first three. We’ll only look at the first three. Brief History/OverviewBrief History/OverviewDatabase Normalization was first proposed by Database Normalization was first proposed by Edgar F. Codd.Edgar F. Codd.Codd defined the first three Normal Forms, which Codd defined the first three Normal Forms, which we’ll look into, of the 7 known Normal Forms.we’ll look into, of the 7 known Normal Forms.In order to do normalization we must know what In order to do normalization we must know what the requirements are for each of the three Normal the requirements are for each of the three Normal Forms that we’ll go over.Forms that we’ll go over.One of the key requirements to remember is that One of the key requirements to remember is that Normal Forms are progressive. That is, in order to Normal Forms are progressive. That is, in order to have 3have 3rdrd NF we must have 2 NF we must have 2ndnd NF and in order to NF and in order to have 2have 2ndnd NF we must have 1 NF we must have 1stst NF. NF.11st st Normal FormNormal FormThe RequirementsThe RequirementsThe requirements to satisfy the 1The requirements to satisfy the 1stst NF: NF:Each table has a primary key: minimal set Each table has a primary key: minimal set of attributes which can uniquely identify a of attributes which can uniquely identify a recordrecordThe values in each column of a table are The values in each column of a table are atomic (No multi-value attributes allowed).atomic (No multi-value attributes allowed).There are no repeating groups: two There are no repeating groups: two columns do not store similar information in columns do not store similar information in the same table.the same table.11st st Normal FormNormal FormExampleExampleUn-normalized Students Un-normalized Students table:table:Normalized Students table:Normalized Students table:StudentStudent##AdvIAdvIDDAdvNamAdvNameeAdvRooAdvRoommClassClass11ClassClass22123123123A123AJamesJames555555102-8102-8104-9104-9124124123B123BSmithSmith467467209-0209-0102-8102-8StudentStudent##AdvIAdvIDDAdvNamAdvNameeAdvRooAdvRoommClassClass##123123123A123AJamesJames555555102-8102-8123123123A123AJamesJames555555104-9104-9124124123B123BSmithSmith467467209-0209-0124124123B123BSmithSmith467467102-8102-822nd nd Normal FormNormal FormThe RequirementsThe RequirementsThe requirements to satisfy the 2The requirements to satisfy the 2ndnd NF:NF:All requirements for 1All requirements for 1stst NF must be met. NF must be met.Redundant data across multiple rows of Redundant data across multiple rows of a table must be moved to a separate a table must be moved to a separate table.table.The resulting tables must be related to each The resulting tables must be related to each other by use of foreign key.other by use of foreign key.22nd nd Normal FormNormal Form Example ExampleStudents tableStudents tableRegistration tableRegistration tableStudent#Student#AdvIDAdvIDAdvNameAdvNameAdvRoomAdvRoom123123123A123AJamesJames555555124124123B123BSmithSmith467467StudentStudent##ClassClass##123123102-8102-8123123104-9104-9124124209-0209-0124124102-8102-833rdrd Normal Form Normal FormThe RequirementsThe RequirementsThe requirements to satisfy the 3The requirements to satisfy the 3rdrd NF:NF:All requirements for 2All requirements for 2ndnd NF must be met. NF must be met.Eliminate fields that do not depend on Eliminate fields that do not depend on the primary key;the primary key;That is, any field that is dependent not only That is, any field that is dependent not only on the primary key but also on another field on the primary key but also on another field must be moved to another table.must be moved to another table.33rdrd Normal Form Normal Form Example ExampleStudents table:Students table:Student table:Student table:Advisor table:Advisor table:Student#Student#AdvIDAdvIDAdvNameAdvNameAdvRoomAdvRoom123123123A123AJamesJames555555124124123B123BSmithSmith467467StudentStudent##AdvIAdvIDD123123123A123A124124123B123BAdvIDAdvIDAdvNamAdvNameeAdvRooAdvRoomm123A123AJamesJames555555123B123BSmithSmith46746733rdrd Normal Form Normal Form Example Cont. Example Cont.Students table:Students table:Registration table:Registration table:Advisor table:Advisor
View Full Document