1 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski Chapter 5 Database Design 1: Normalization
2 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski Objectives u Discuss functional dependence u Define first normal form, second normal form, and third normal form u Describe the problems associated with tables (relations) that are not in first normal form, second normal form, or third normal form along with the mechanism for converting to all three
3 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski Objectives u Discuss the problems associated with incorrect conversions to third normal form u Define fourth normal form u Describe the problems associated with tables (relations) that are not in fourth normal form and describe the mechanism for converting to fourth normal form
4 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski Functional Dependence u Column B is functionally dependent on Column A if A’s value determines a single value for B at a given time u Given A, a single value for B can be determined
5 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski Functional Dependence Example Figures Rep Table Where LastName can determine record Rep Table Where LastName cannot determine record
6 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski Keys u Column(s) C is primary key for table T if: Property 1: All columns in T are functionally dependent on C Property 2: No subcollection of columns in C (assuming C is a collection of columns and not just a single column) also has Property 1 u Candidate Keys l Column(s) on which all other columns in table are functionally dependent u Alternate Keys l Candidate keys not chosen as primary keys
7 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski First Normal Form (1NF) u Unnormalized table l Contains a repeating group u Table in 1NF l Contains no repeating groups u Removal of repeating groups is starting point in quest for problem-free tables
8 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski 1NF Example Figure 5.5 Unnormalized Table
9 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski 1NF Example (con’t.) Figure 5.6 Conversion to 1NF
10 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski Second Normal Form (2NF) u 1NF Tables may contain problems l Redundancy l Update Anomalies u Update, inconsistent data, additions, deletions u Occur because a column is dependent on a portion of a multi-column primary key u 2NF Table l In 1NF and no nonkey column is dependent on only a portion of the primary key
11 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski Dependency Diagram for Orders Figure 5.8
12 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski 2NF Example Figure 5.9a
13 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski 2NF Example Figure 5.9b
14 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski Third Normal Form (3NF) u 2NF Tables may still contain problems l Redundancy and wasted space l Update Anomalies u Update, inconsistent data, additions, deletions u Occur because a column is dependent on a portion of a multi-column primary key u 3NF Table l In 2NF and the only determinants contained are candidate keys
15 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski Customers Dependency Diagram Figure 5.11
16 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski 3NF Example Figure 5.12a
17 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski 3NF Example Figure 5.12b
18 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski Incorrect Decomposition Example Figure 5.13a
19 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski Incorrect Decomposition Example Figure 5.13b
20 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski 2nd Incorrect Decomposition Figure 5.14a
21 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski 2nd Incorrect Decomposition Figure 5.14b
22 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski Fourth Normal Form (4NF) u 3NF Tables may still contain problems l Dependencies l Update Anomalies u Update, additions, deletions u Occur because of multivalued dependencies u 4NF Table l In 3NF and has no multivalued dependencies
23 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski Incorrect 4NF Example Figure 5.15
24 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski 4NF Example Figure 5.16a
25 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski 4NF Example Figure 5.16b
26 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski Normal Forms Figure 5.17