190 likes | 356 Views
Normalization. Are we Normal. Normalization. Normalization is the process of converting complex data structures into simple, stable data structures It also is the process of removing from a database certain “anomalies”. Anomalies.
E N D
Normalization Are we Normal
Normalization • Normalization is the process of converting complex data structures into simple, stable data structures • It also is the process of removing from a database certain “anomalies”
Anomalies • Update anomalies—you have to update a record in a number of different places • Insertion anomalies—Example: in order to insert a new employee a project must be assigned. If there is no project yet a phantom one must be created. • Deletion anomalies—Two types: when you delete a record other vital information is lost, or must delete in several places with the possibility of leaving unattached data islands
Normal Forms • There are many Normal Forms—or stages of normalization possible, but we will only focus on the first three.
First Normal Form • There are no duplicated rows in the table. • Each cell is single-valued (i.e., there are no repeating groups or arrays). • Entries in a column (attribute, field) are of the same kind.
Example Table 1 CDS Table 1
Normalizing • The sample tables have repeating groups—ie the tracks associated with each CD. • Each column must contain only a single value • You also don’t want to find yourself numbering columns like track1, etc. • The next table puts the sample table into first normal form
Second Normal Form • A table is in 2NF if it is in 1NF and if all non-key attributes are dependent on all of the key and nothing else. • This is called functional dependency
Normalizing. . . • In our sample table there are really two separate things going on • One is the CD information and one is the track information- • To get all track information creates a lot of redundancy in the CD information • Each should be dependent on their own key
Third Normal Form • A table is in 3NF if it is in 2NF and if it has no transitive dependencies. • This means that the non primary key attributes don’t depend on each other. • Look at our second sample table:
Normalizing • There is a transitive dependency here • Artist Country is dependent on Artist, not on TrackID which is the key field of the table • The following tables resolve this:
Summary • Through the process of normalization our original table has become three tables, related by foreign keys: CDs(CDID, CDTitle) ARTISTS(ArtistID, Artist, ArtistCountry) TRACKS(TrackID, TrackTitle, CDID, ArtistID)
MORE… • Boyce Codd Normal Form • Fourth Normal Form • Fifth Normal Form