Presentation is loading. Please wait.

Presentation is loading. Please wait.

Normalization. We will take a look at –First Normal Form –Second Normal Form –Third Normal Form There are also –Boyce-Codd, Fourth and Fifth normal forms.

Similar presentations


Presentation on theme: "Normalization. We will take a look at –First Normal Form –Second Normal Form –Third Normal Form There are also –Boyce-Codd, Fourth and Fifth normal forms."— Presentation transcript:

1 Normalization

2 We will take a look at –First Normal Form –Second Normal Form –Third Normal Form There are also –Boyce-Codd, Fourth and Fifth normal forms In most cases the first three normal forms are enough

3 normalization Why normalization –Avoid redundancy –Minimize risk for inconsistent data –Make it easier to maintain the database –The database takes less space –Avoid Anomalies When inserting, updating or deleting data

4 Normalization A table must always have a primary key with unique values for each row. An unnormalized table –Table that contains one or more repeating data groups. First Normal Form (1NF) A relation in which the intersection of each row and column contains one and only one value.

5 First Normal Form (1NF) Typically a DB Relation (table) should: –A table must have a primary key with unique values for each row, i.e uniquly indetifies each row in the table. –Each intersection (cell) in the table contains only one value –An attribute (column) should not be present more than once.

6 Table student, unnormalized studentnrnameclassStudentcounsellorsubjectgradesubjectgradesubjectgrade 16peterB2JensenDanish7Math8IT7 24UllaA3Madsen Econo mic6 31NielsB2Jensen Econo mic8 43LenaA5AndersenEnglish6IT6 44FieB2JensenMath9 45LarsA1NielsenEnglish8Math7IT8

7 Table Student, 1NF studentnrnameclassStudentcounsellorsubjectmark 16peterB2JensenDanish7 16peterB2JensenMath8 16peterB2JensenIT7 24UllaA3MadsenEconomic6 31NielsB2JensenEconomic8 43LenaA5AndersenEnglish6 43LenaA5AndersenIT6 44FieB2JensenMath9 45LarsA1NielsenEnglish8 45LarsA1NielsenMath7 45LarsA1NielsenIT8

8 Second Normal Form Second normal form (2NF) –A relation that is in 1NF and every non-primary-key attribute is fully functionally dependent on the primary key. This means: –The table is in 1NF –No attribute (column) which is not part of primary key, may depend on part of the primary key. –(Can only be a problem in tables with PK consisting of several attributes)

9 Udlaan table, 1NF Laan: lending (library) BogID: Book ID Forfatter: Writer Forlag: Publisher

10 2NF, two solution alternatives

11 Problem normalization to 1NF

12 Afdeling table, problem normalization to 2NF

13 Third Normal Form Third normal form (3NF) –A relation that is in 2NF and in which no non-primary- key attribute is transitively dependent on the primary key. This means: –The table is in 2NF –No attribute (column) may depend on any other column which is not the primary key.

14 Kunde table, think how to normalize to 3NF


Download ppt "Normalization. We will take a look at –First Normal Form –Second Normal Form –Third Normal Form There are also –Boyce-Codd, Fourth and Fifth normal forms."

Similar presentations


Ads by Google