Presentation is loading. Please wait.

Presentation is loading. Please wait.

4 Normal Form.

Similar presentations


Presentation on theme: "4 Normal Form."— Presentation transcript:

1 4 Normal Form

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 1st Normal Form Example Un-normalized Students table:
102-8 209-0 467 Smith 123B 124 104-9 555 James 123A 123 Class2 Class1 AdvRoom AdvName AdvID Student# 209-0 467 Smith 123B 124 104-9 555 James 123A 123 102-8 Class# AdvRoom AdvName AdvID Student#

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 2nd Normal Form Example Students table Registration table 467 Smith
124 555 James 123A 123 AdvRoom AdvName AdvID Student# 209-0 124 104-9 123 102-8 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

10 Region Salesperson Name Cust_ID Region Salesperson 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: Candidate keys:
A, B, C, and D Candidate keys: Since all the determinants are candidate keys, this is BCNF.

14 4th 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 Singing Arabic 200 Cooking English French 100 Politic
Assume the following relation: Employee (Eid:pk1, Language:pk2, Skill:pk3) Singing Arabic 200 Cooking English French 100 Politic Kurdish Teaching Skill Language Eid

19 4 NF Example (conti...) Singing Arabic 200 Cooking English French 100
Politic Kurdish Teaching Skill Language Eid 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 --->> Languages Eid --->> 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...) Singing Arabic 200 Cooking English French 100
Thus employee 100 when she teaches, she uses English; but when she cooks, she uses French. This relation is in fourth normal form. Singing Arabic 200 Cooking English French 100 Politic Kurdish Teaching Skill Language Eid

22 Not 4 NF Example Assume the following relation with multivalued dependency:   Employee (Eid:pk1, Languages:pk2, Skills:pk3) Eid --->> Languages Eid --->> Skills Languages and Skills are independent.

23 Not 4 NF Example (conti...) Singing Arabic 200 Cooking French 100 Politic Kurdish Teaching English Skill Language Eid 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 Not 4 NF Example (conti...) Here is the table after the insertion:
Singing English 200 Cooking Arabic Teaching Kurdish 100 Politics Skill Language Eid

25 Conclusion of Steps in Normalization

26 References http://www.cs.sjsu.edu/faculty/lee/cs157/cs157a.html


Download ppt "4 Normal Form."

Similar presentations


Ads by Google