Normalization - Mimozamimoza.marmara.edu.tr/~gozde.alp/cse355/PS/2017/week11/...NORMAL FORMS...
Transcript of Normalization - Mimozamimoza.marmara.edu.tr/~gozde.alp/cse355/PS/2017/week11/...NORMAL FORMS...
![Page 1: Normalization - Mimozamimoza.marmara.edu.tr/~gozde.alp/cse355/PS/2017/week11/...NORMAL FORMS 1NF(First Normal Form): An entity is in 1NF when it contains no repeating groups of data.](https://reader035.fdocuments.net/reader035/viewer/2022071512/613329b6dfd10f4dd73ae913/html5/thumbnails/1.jpg)
NORMALIZATION
26th-27th November 2015
Gözde ALP
![Page 2: Normalization - Mimozamimoza.marmara.edu.tr/~gozde.alp/cse355/PS/2017/week11/...NORMAL FORMS 1NF(First Normal Form): An entity is in 1NF when it contains no repeating groups of data.](https://reader035.fdocuments.net/reader035/viewer/2022071512/613329b6dfd10f4dd73ae913/html5/thumbnails/2.jpg)
CONTENT
Normal Forms
FD (Functional Dependencies)
Finding Candidate Key
Exercises
![Page 3: Normalization - Mimozamimoza.marmara.edu.tr/~gozde.alp/cse355/PS/2017/week11/...NORMAL FORMS 1NF(First Normal Form): An entity is in 1NF when it contains no repeating groups of data.](https://reader035.fdocuments.net/reader035/viewer/2022071512/613329b6dfd10f4dd73ae913/html5/thumbnails/3.jpg)
NORMAL FORMS
1NF(First Normal Form): An entity is in 1NF
when it contains no repeating groups of data.
2NF(Second Normal Form): When it is in 1NF
and when all of its attributes are fully
dependent on its primary key.
3NF(Third Normal Form): An entity type is in
3NF when it is in 2NF and when all of its
attributes are directly dependent on the
primary key
![Page 4: Normalization - Mimozamimoza.marmara.edu.tr/~gozde.alp/cse355/PS/2017/week11/...NORMAL FORMS 1NF(First Normal Form): An entity is in 1NF when it contains no repeating groups of data.](https://reader035.fdocuments.net/reader035/viewer/2022071512/613329b6dfd10f4dd73ae913/html5/thumbnails/4.jpg)
FD (FUNCTIONAL DEPENDENCIES)
FDs are constraints that are derived from the
meaning and interrelationships of the data
attributes
ID ‐> email, city, country, surname
![Page 5: Normalization - Mimozamimoza.marmara.edu.tr/~gozde.alp/cse355/PS/2017/week11/...NORMAL FORMS 1NF(First Normal Form): An entity is in 1NF when it contains no repeating groups of data.](https://reader035.fdocuments.net/reader035/viewer/2022071512/613329b6dfd10f4dd73ae913/html5/thumbnails/5.jpg)
1NF
All the attributes in a relation must have atomic
domains. The values in an atomic domain are
indivisible units.
Multivalued attributes
1NF
![Page 6: Normalization - Mimozamimoza.marmara.edu.tr/~gozde.alp/cse355/PS/2017/week11/...NORMAL FORMS 1NF(First Normal Form): An entity is in 1NF when it contains no repeating groups of data.](https://reader035.fdocuments.net/reader035/viewer/2022071512/613329b6dfd10f4dd73ae913/html5/thumbnails/6.jpg)
2NF Every non-prime attribute should be fully functionally
dependent on prime key attribute. Prime key attributes are
Stu_ID and Proj_ID. Stu_Name and Proj_Name must be
dependent upon both and not on any of the prime key attribute
individually.
Partial dependency
2NF
![Page 7: Normalization - Mimozamimoza.marmara.edu.tr/~gozde.alp/cse355/PS/2017/week11/...NORMAL FORMS 1NF(First Normal Form): An entity is in 1NF when it contains no repeating groups of data.](https://reader035.fdocuments.net/reader035/viewer/2022071512/613329b6dfd10f4dd73ae913/html5/thumbnails/7.jpg)
3NF Stu_ID is the key and only prime key attribute. We find
that City can be identified by Stu_ID as well as Zip
itself. Neither Zip is a superkey nor is City a prime
attribute. Additionally, Stu_ID → Zip → City, so there
exists transitive dependency.
3NF
![Page 8: Normalization - Mimozamimoza.marmara.edu.tr/~gozde.alp/cse355/PS/2017/week11/...NORMAL FORMS 1NF(First Normal Form): An entity is in 1NF when it contains no repeating groups of data.](https://reader035.fdocuments.net/reader035/viewer/2022071512/613329b6dfd10f4dd73ae913/html5/thumbnails/8.jpg)
EXERCISE 1
Enrollment( studentID, courseCode, sName, sSurname,
courseName, grade)
FD1: studentID sName, sSurname
FD2: courseCodecourseName
FD3: studentID, courseCodegrade
Funtional dependencies of Enrollment table is illustrated below.
a. What is the normal form of this relation?
![Page 9: Normalization - Mimozamimoza.marmara.edu.tr/~gozde.alp/cse355/PS/2017/week11/...NORMAL FORMS 1NF(First Normal Form): An entity is in 1NF when it contains no repeating groups of data.](https://reader035.fdocuments.net/reader035/viewer/2022071512/613329b6dfd10f4dd73ae913/html5/thumbnails/9.jpg)
EXERCISE 1
b. Decompose the relations into 3NF step by
step.
![Page 10: Normalization - Mimozamimoza.marmara.edu.tr/~gozde.alp/cse355/PS/2017/week11/...NORMAL FORMS 1NF(First Normal Form): An entity is in 1NF when it contains no repeating groups of data.](https://reader035.fdocuments.net/reader035/viewer/2022071512/613329b6dfd10f4dd73ae913/html5/thumbnails/10.jpg)
FINDING CANDIDATE KEY
If the prime attribute is not given, how can we
find candidate key?
By help of transitive closure
![Page 11: Normalization - Mimozamimoza.marmara.edu.tr/~gozde.alp/cse355/PS/2017/week11/...NORMAL FORMS 1NF(First Normal Form): An entity is in 1NF when it contains no repeating groups of data.](https://reader035.fdocuments.net/reader035/viewer/2022071512/613329b6dfd10f4dd73ae913/html5/thumbnails/11.jpg)
EXERCISE 2
Find candidate key of the following relation.
R(A,B,C,D,E,F)
FD1: AC
FD2: CD
FD3: DB
FD4: EF
![Page 12: Normalization - Mimozamimoza.marmara.edu.tr/~gozde.alp/cse355/PS/2017/week11/...NORMAL FORMS 1NF(First Normal Form): An entity is in 1NF when it contains no repeating groups of data.](https://reader035.fdocuments.net/reader035/viewer/2022071512/613329b6dfd10f4dd73ae913/html5/thumbnails/12.jpg)
EXERCISE 3
Find candidate key of the following relation.
R(A,B,C,D)
FD1: CD
FD2: CA
FD3: BC
![Page 13: Normalization - Mimozamimoza.marmara.edu.tr/~gozde.alp/cse355/PS/2017/week11/...NORMAL FORMS 1NF(First Normal Form): An entity is in 1NF when it contains no repeating groups of data.](https://reader035.fdocuments.net/reader035/viewer/2022071512/613329b6dfd10f4dd73ae913/html5/thumbnails/13.jpg)
EXERCISE 4
Find candidate key of the following relation.
R(A,B,C,D,E,F)
FD1: AB,C,D,E,F
FD2: B,CA,D,E,F
FD3: BF
FD4: DE
![Page 14: Normalization - Mimozamimoza.marmara.edu.tr/~gozde.alp/cse355/PS/2017/week11/...NORMAL FORMS 1NF(First Normal Form): An entity is in 1NF when it contains no repeating groups of data.](https://reader035.fdocuments.net/reader035/viewer/2022071512/613329b6dfd10f4dd73ae913/html5/thumbnails/14.jpg)
EXERCISE 5
What is the normal form of this relation?
Decompose the relation into 3NF step by step
according to the candidate key you find in 4th
exercise.
R(A,B,C,D,E,F)
FD1: B,CA,D,E,F
FD2: BF
FD3: DE
![Page 15: Normalization - Mimozamimoza.marmara.edu.tr/~gozde.alp/cse355/PS/2017/week11/...NORMAL FORMS 1NF(First Normal Form): An entity is in 1NF when it contains no repeating groups of data.](https://reader035.fdocuments.net/reader035/viewer/2022071512/613329b6dfd10f4dd73ae913/html5/thumbnails/15.jpg)
EXERCISE 6
Find the candidate key of following relation.
R(A,B,C,D)
FD1: A,BC
FD2: BD
What is the normal form of this relation?
Decompose the relation into 3NF step by step.
![Page 16: Normalization - Mimozamimoza.marmara.edu.tr/~gozde.alp/cse355/PS/2017/week11/...NORMAL FORMS 1NF(First Normal Form): An entity is in 1NF when it contains no repeating groups of data.](https://reader035.fdocuments.net/reader035/viewer/2022071512/613329b6dfd10f4dd73ae913/html5/thumbnails/16.jpg)
EXERCISE 7
R(A,B,C,D,E,F,G,H,I,J,K,M)
FD1: AJ,K
FD2: BD,E
FD3: FG,H
FD4: IC
Assume key is ABC. What is the normal form of
this relation?
Decompose the relation into 3NF step by step.
![Page 17: Normalization - Mimozamimoza.marmara.edu.tr/~gozde.alp/cse355/PS/2017/week11/...NORMAL FORMS 1NF(First Normal Form): An entity is in 1NF when it contains no repeating groups of data.](https://reader035.fdocuments.net/reader035/viewer/2022071512/613329b6dfd10f4dd73ae913/html5/thumbnails/17.jpg)
REFERENCES
http://www.cs.toronto.edu/~ryanjohn/teaching
/cscc43-s12/lectures/c43-fd-v06.pdf
http://www.tutorialspoint.com/dbms/database
_normalization.htm