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...
NORMALIZATION
26th-27th November 2015
Gözde ALP
CONTENT
Normal Forms
FD (Functional Dependencies)
Finding Candidate Key
Exercises
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
FD (FUNCTIONAL DEPENDENCIES)
FDs are constraints that are derived from the
meaning and interrelationships of the data
attributes
ID ‐> email, city, country, surname
1NF
All the attributes in a relation must have atomic
domains. The values in an atomic domain are
indivisible units.
Multivalued attributes
1NF
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
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
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?
EXERCISE 1
b. Decompose the relations into 3NF step by
step.
FINDING CANDIDATE KEY
If the prime attribute is not given, how can we
find candidate key?
By help of transitive closure
EXERCISE 2
Find candidate key of the following relation.
R(A,B,C,D,E,F)
FD1: AC
FD2: CD
FD3: DB
FD4: EF
EXERCISE 3
Find candidate key of the following relation.
R(A,B,C,D)
FD1: CD
FD2: CA
FD3: BC
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
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
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.
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.
REFERENCES
http://www.cs.toronto.edu/~ryanjohn/teaching
/cscc43-s12/lectures/c43-fd-v06.pdf
http://www.tutorialspoint.com/dbms/database
_normalization.htm