7
Normalization Process: Exercise 1: Step 1 IST210 1 Step 1. Identify all the candidate keys of the relation. StudentNumber

Normalization Process: Exercise 1: Step 1 IST2101 Step 1. Identify all the candidate keys of the relation. StudentNumber

Embed Size (px)

Citation preview

Page 1: Normalization Process: Exercise 1: Step 1 IST2101 Step 1. Identify all the candidate keys of the relation. StudentNumber

IST210 1

Normalization Process: Exercise 1: Step 1

Step 1. Identify all the candidate keys of the relation.

StudentNumber

Page 2: Normalization Process: Exercise 1: Step 1 IST2101 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)

Page 3: Normalization Process: Exercise 1: Step 1 IST2101 Step 1. Identify all the candidate keys of the relation. StudentNumber

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

Page 4: Normalization Process: Exercise 1: Step 1 IST2101 Step 1. Identify all the candidate keys of the relation. StudentNumber

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

Page 5: Normalization Process: Exercise 1: Step 1 IST2101 Step 1. Identify all the candidate keys of the relation. StudentNumber

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

Page 6: Normalization Process: Exercise 1: Step 1 IST2101 Step 1. Identify all the candidate keys of the relation. StudentNumber

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)

Page 7: Normalization Process: Exercise 1: Step 1 IST2101 Step 1. Identify all the candidate keys of the relation. StudentNumber

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: