Presentation is loading. Please wait.

Presentation is loading. Please wait.

Database Design: Normalization J.G. Zheng June 29 th 2005 DB Chapter 4.

Similar presentations

Presentation on theme: "Database Design: Normalization J.G. Zheng June 29 th 2005 DB Chapter 4."— Presentation transcript:

1 Database Design: Normalization J.G. Zheng June 29 th 2005 DB Chapter 4

2 2 Overview Normalization First three normal forms

3 3 Introduction/Review Two perspectives to design database E-R Diagram (top-down) Normalization (bottom-up) Normalization is a process of efficiently modeling data, by analyzing relationships between attributes The goal is to remove redundancy and anomaly Usually a table is divided into 2 or more tables Combining the two perspectives in practice

4 4 Normal Forms Normal forms are guidelines (steps) for the normalization process Unnormalized Form (UNF) 1st Normal Form (1NF) 2nd Normal Form (2NF) 3rd Normal Form (3NF) Boyce Codd Normal Form (BC/NF) 4th Normal Form (4NF) 5th Normal Form DK/NF Fewer anomalies... …but more tables Normalization

5 5 Normalization – 1NF A relation is in 1NF if it satisfies the definition of a relation Review: what are the characteristics of a relation? Particularly No repeating value sets (single value property)

6 6 Transforming to 1NF Row transformation (Figure 4.5 and 4.6 on page 287) UNF1NF

7 7 Higher Normal Forms Normal forms higher than 1NF deal with functional dependence Identify which normal form the table is by analyzing the functional dependence between attributes (fields)

8 8 Functional Dependence If each value of attribute A is associated with only one value of attribute B, we say A determines B Or, B is dependent on A Denoted as: A B Functional dependence describes relationships between attributes (not relations) Note: A (or B) could be a set of fields

9 9 Functional Dependence Examples Dependence example For each SSN, there is only one corresponding first name (or last name), so: SSN determines FirstName SSN FirstName Non-dependence example Each instructor teaches multiple courses, so: InstructorId does not determines CourseNumber

10 10 Functional Dependence and Keys By definition, primary key functionally determines all other attributes Primary key Surrogate key Composite primary key Dependency diagram ISBNTitlePubDateListPrice

11 11 Functional Dependency Exercise CustomerNum CustomerName? {Street, City, State} Zip? CustomerName Balance? State (?) Zip RepNum ( ? ) CustomerName

12 12 Normalization – 2NF A relation is in 2NF, if It is in 1 st normal formal, and All nonkey attributes must be functionally dependent on the whole primary key (Fully dependence) No partial dependence It also implies that a relation is in 2NF if the primary key is a single attribute

13 13 2NF Identify primary key (PK) If PK consists of only one field, then it is in 2NF If PK is a composite key, then analyze functional dependence between part of primary key and other non-key attributes

14 14 Normalization – 3NF A relation is in 3NF, if It is in 2 nd normal formal, and All attributes must, and only, be functionally dependent on candidate keys 3NF deals with [transitive dependence] A B C No transitive dependence

15 15 3NF Identify primary key (PK) and Look for transitive dependence

16 16 Some Practical Tips If there are attributes of two different entities in one table, there are usually anomalies To identify the normalization level, determine the primary key first; then look for partial dependence and transitive dependence

17 17 Normalization Exercise 1 Which normal form is the above table in? A. 1NF B. 2NF C. 3NF D. UNF

18 18 Normalization Exercise 2 Which normal form is the above table (2 nd one) in? A. 1NF B. 2NF C. 3NF D. UNF

19 19 Normalization Exercise 3 Which normal form is the above table (first one) in? 1NF 2NF 3NF UNF

20 20 Final database design with 3 tables

21 21 Summary

Download ppt "Database Design: Normalization J.G. Zheng June 29 th 2005 DB Chapter 4."

Similar presentations

Ads by Google