Presentation is loading. Please wait.

Presentation is loading. Please wait.

Normalization Are we Normal. Normalization Normalization is the process of converting complex data structures into simple, stable data structures It also.

Similar presentations


Presentation on theme: "Normalization Are we Normal. Normalization Normalization is the process of converting complex data structures into simple, stable data structures It also."— Presentation transcript:

1 Normalization Are we Normal

2 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”

3 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

4 Normal Forms There are many Normal Forms—or stages of normalization possible, but we will only focus on the first three.

5 First Normal Form 1. There are no duplicated rows in the table. 2. Each cell is single-valued (i.e., there are no repeating groups or arrays). 3. Entries in a column (attribute, field) are of the same kind.

6 Example Table 1 CDIDCDTITLETrackTitleArtistArtist Country 1Sergeant PepperSergeant Pepper, Lucy in the Sky, With a little Help BeatlesUK 2Blood on the TracksTangled up in Blue, Idiot Wind DylanUS CDS Table 1

7 Another Example Table CDIDCDTitleTrack1Track2Track3 1Sergeant Pepper Sergeant Peppers lonely hearts club band Lucy in the sky with diamonds With a little help 2Blood on the Tracks Tangled up in Blue Idiot WindBucket of Rain

8 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

9 First Normal Form Sample CDIDCDTITLETrackTitleArtistArtist Country 1Sergeant Pepper BeatlesUK 1Sergeant PepperLucy in the SkyBeatlesUK 1Sergeant PepperWith a little HelpBeatlesUK 2Blood on the TracksTangled up in Blue DylanUS 2Blood on the TracksIdiot WindDylanUS

10 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

11 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

12 Second Normal Form Sample CDIDCDTitle 1Sergeant Pepper 2Blood on the Tracks TrackIDTrackTitleCDIDArtistArtist Country 1Sergeant Pepper1BeatlesUK 2Lucy in the Sky1BeatlesUK 3With a little help1BeatlesUK 4Tangled up in Blue2DylanUS 5Idiot Wind2DylanUS

13 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:

14 Sample Table TrackIDTrackTitleCDIDArtistArtist Country 1Sergeant Pepper1BeatlesUK 2Lucy in the Sky1BeatlesUK 3With a little help1BeatlesUK 4Tangled up in Blue2DylanUS 5Idiot Wind2DylanUS

15 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:

16 Better TrackIDTrackTitleCDIDArtistID 1Sergeant Pepper11 2Lucy in the Sky11 3With a little Help11 4Tangled up in Blue22 5Idiot wind22 ArtistIDArtistArtistCountry 1BeatlesUK 2DylanUS

17 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)

18 MORE… 1. Boyce Codd Normal Form 2. Fourth Normal Form 3. Fifth Normal Form


Download ppt "Normalization Are we Normal. Normalization Normalization is the process of converting complex data structures into simple, stable data structures It also."

Similar presentations


Ads by Google