Upload
gavin-leonard
View
218
Download
1
Embed Size (px)
Citation preview
IST210 1
Normalization Process: Exercise 1: Step 1
Step 1. Identify all the candidate keys of the relation.
StudentNumber
IST210 2
Normalization Process: Exercise 1: Step 2
Step 2. Identify all the functional dependencies in the relation.
• DormName DormCost
Trivial dependency:StudentNumber (LastName, FirstName, DormName, DormCost)
IST210 3
Normalization Process: Exercise 1: Step 3
Step 3. If any determinant is not a candidate key, the relation is not well formed.
StudentNumber StudentNumber (LastName, FirstName, DormName, DormCost)DormName DormCost
IST210 4
Normalization Process: Exercise 1: Step 3
Step 3. Examine the determinants of the functional dependencies. If any determinant is not a candidate key, the relation is not well formed. In this case:
a. Place the columns of the functional dependency in a new relation of their own.
DORM(DormName, DormCost)b. Make the determinant of the functional dependency the primary key
of the new relation.DORM(DormName, DormCost)
c. Leave a copy of the determinant as a foreign key in the original relation.
STU_DORM(StudentNumber, LastName, FirstName, DormName)d. Create a referential integrity constraint between the original relation
and the new relation.DormName in STU_DORM must exist in DormName in DORM
IST210 5
Normalization Process: Exercise 1: Step 4
Step 4. Repeat step 3 as many times as necessary until every determinant of every relation is a candidate key.
STU_DORM(StudentNumber, LastName, FirstName, DormName)DORM(DormName, DormCost)
DormName in STU_DORM must exist in DormName in DORM
Well-formed relational model design
How to place the foreign key?
Q: In Step 3, why don’t we connect these two tables by placing StudentNumber into DORM table instead?A: Each dorm may correspond to multiple students, resulting multiple values in single cell.
STU_DORM(StudentNumber, LastName, FirstName, DormName)DORM(DormName, DormCost)
IST210 7
How to place the foreign key?
STUDENT(StudentID, StudentName, Student’sDepartment, Email)COURSE(CourseID, Instructor, CourseName, Location)REGISTRATION(StudentID, CourseID)
StudentID in REGISTRATION must exist in StudentID in STUDENTCOURSEID in REGISTRATION must exist in CourseID in COURSE
Sometimes it is inappropriate to place the primary key from either table to another. In such cases, we need to create a new table to connect them together: