Download presentation
Presentation is loading. Please wait.
1
4 Normal Form Nathanael Chow CS 157A Fall 2006 Dr. Lee
2
Overview ● 1 NF ● 2 NF ● 3 NF ● BCNF ● 4 NF ● Conclusion
3
Database Normalization ● Each data in the database should represent once ● Purpose of normalization: to eliminate insert, update, and delete anomalies
4
First Normal Form (1 NF) ● All values in the columns are atomic (simple, indivisible). This is, they contain no repeating values. ● There are no repeating groups: two columns do not store similar information in the same table. ● Basically: 1 NF is to eliminate duplicate columns
5
1 st Normal Form Example Un-normalized Students table: Normalized Students table: 102-8209-0467Smith123B124 104-9102-8555James123A123 Class2Class1AdvRoomAdvNameAdvIDStudent# 209-0467Smith123B124 104-9555James123A123 102-8467Smith123B124 102-8555James123A123 Class#AdvRoomAdvNameAdvIDStudent#
6
Second Normal Form (2 NF) ● A relation is in 2 NF if it is in 1 NF and every non-key attribute is fully functionally dependant on the primary key
7
2 nd Normal Form Example Students table Registration table 467Smith123B124 555James123A123 AdvRoomAdvNameAdvIDStudent# 209-0124 104-9123 102-8124 102-8123 Class#Student#
8
Third Normal Form (3 NF) ● A relation is in 3 NF if it is 2 NF and no transitive dependencies exist. ● Transitive dependency is a functional dependency between non-key attribute ● Basically: 3 NF is to eliminate column not depend upon the primary key.
9
transitive dependency Region Salesperson Name Cust_ID transitive dependency
10
Salesperson Name Cust_ID RegionSalesperson Region Salesperson Name Cust_ID
11
Boyce-Codd Normal Form (BCNF) ● A relation is in BCNF if it is in 3 NF and every determinant is a candidate key; in other words, each determinant can be used as a primary key. ● Determinant: an attribute on which some other attribute is fully functionally dependent Ex: A --> B (A is called the determinant)
12
BCNF Example ● Given: R (A, B, C, D) ● A --> B, C, D ● B --> A, C, D ● C --> A, B, D ● D --> A, B, C
13
BCNF Example (Cont...) ● Determinants: A, B, C, and D ● Candidate keys: A, B, C, and D ● Since all the determinants are candidate keys, this is BCNF.
14
4 th Normal Form (4 NF) ● A relation is a 4 NF if it is BCNF and There is no multivalued dependency in the relation or There are multivalued dependency but the attributes, which are multivalued dependent on a specific attribute, are dependent between themselves ● What is a multivalued dependency (MVD)?
15
Definition of MVD ● A multivalued dependency X->-> Y is an assertion that if two tuples of a relation agree on all the attributes of X, then their components in the set of attributes Y may be swapped, and the result will be two tuples that are also in the relation
16
MVD Example R(x, y, z)
17
MVD Example R(x, y, z)
18
4 NF Example SingingArabic200 CookingEnglish200 CookingFrench100 PoliticKurdish100 TeachingEnglish100 SkillLanguageEid Assume the following relation: Employee (Eid:pk1, Language:pk2, Skill:pk3)
19
4 NF Example (conti...) SingingArabic200 CookingEnglish200 CookingFrench100 PoliticKurdish100 TeachingEnglish100 SkillLanguageEid Recall that a relation is in BCNF if all its determinant are candidate keys. Because relation Employee has only one determinant (Eid, Language, Skill), which is the composite primary key. Since the primary is a candidate key, R is in BCNF. Assume that there is no MVD, then this relation is 4 NF.
20
4 NF Example (conti...) Assume the following relation with multi-value dependency: Employee (Eid:pk1, Languages:pk2, Skills:pk3) Eid --->> LanguagesEid --->> Skills Languages and Skills are dependent. This says an employee speaks several languages and has several skills. However for each skill, a specific language is used when that skill is practiced.
21
4 NF Example (conti...) Thus employee 100 when she teaches, she uses English; but when she cooks, she uses French. This relation is in fourth normal form. SingingArabic200 CookingEnglish200 CookingFrench100 PoliticKurdish100 TeachingEnglish100 SkillLanguageEid
22
Not 4 NF Example Assume the following relation with multivalued dependency: Employee (Eid:pk1, Languages:pk2, Skills:pk3) Eid --->> LanguagesEid --->> Skills Languages and Skills are independent.
23
Not 4 NF Example (conti...) SingingArabic200 CookingFrench100 PoliticKurdish100 TeachingEnglish100 SkillLanguageEid Insertion anomaly: To insert row (200 English Cooking) we have to insert two extra rows (200 Arabic cooking), and (200 English Singing) otherwise the database will be inconsistent.
24
SingingEnglish200 CookingArabic200 CookingEnglish200 SingingArabic200 TeachingKurdish100 PoliticsEnglish100 PoliticsKurdish100 TeachingEnglish100 SkillLanguageEid Not 4 NF Example (conti...) Here is the table after the insertion:
25
Conclusion of Steps in Normalization
26
References ● http://www.cs.sjsu.edu/faculty/lee/cs157/cs157a. html http://www.cs.sjsu.edu/faculty/lee/cs157/cs157a. html ● http://www.cs.sjsu.edu/faculty/lee/cs157/cs157al ecturenotes.htm http://www.cs.sjsu.edu/faculty/lee/cs157/cs157al ecturenotes.htm
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.