Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 2. The Relational Model (cont.) IST2101. Review: Determinant vs. Candidate Key IST2102 DeterminantsCandidate Key (StudentID, CourseID) StudentID.

Similar presentations


Presentation on theme: "Chapter 2. The Relational Model (cont.) IST2101. Review: Determinant vs. Candidate Key IST2102 DeterminantsCandidate Key (StudentID, CourseID) StudentID."— Presentation transcript:

1 Chapter 2. The Relational Model (cont.) IST2101

2 Review: Determinant vs. Candidate Key IST2102 DeterminantsCandidate Key (StudentID, CourseID) StudentID CourseID (StudentID, CourseID) In a relation, a candidate key must be a determinant In a relation, a determinant may not be a candidate key A relation is well-formed if and only if every determinant is a candidate key.

3 Normalization Process 1.Identify all the candidate keys of the relation. 2.Identify all the functional dependencies in the relation. 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. b.Make the determinant of the functional dependency the primary key of the new relation. c.Leave a copy of the determinant as a foreign key in the original relation. d.Create a referential integrity constraint between the original relation and the new relation. 4.Repeat step 3 as many times as necessary until every determinant of every relation is a candidate key. IST2103

4 Normalization Process: Example 1: Step 1 IST2104 Step 1. Identify all the candidate keys of the relation. PrescriptionNumber

5 Normalization Process: Example 1: Step 2 IST2105 Step 2. Identify all the functional dependencies in the relation. Drug  Dosage? No CustomerEmail  (CustomerName, CustomerPhone)? Yes PrescriptionNumber  (Date, Drug, Dosage, CustomerName, CustomerPhone, CustomerEmail) This is a trivial dependency by the definition of candidate key

6 Normalization Process: Example 1: Step 3 IST2106 Step 3. If any determinant is not a candidate key, the relation is not well formed. Determinant: PrescriptionNumber, CustomerEmail Candidate key: PrescriptionNumber CustomerEmail is NOT a candidate key, so the relation NOT well formed Then, we will normalize it (break it into multiple relations)

7 Normalization Process: Example 1: Step 3 IST2107 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. CUSTOMER (CustomerEmail, CustomerName, CustomerPhone) b.Make the determinant of the functional dependency the primary key of the new relation. CUSTOMER (CustomerEmail, CustomerName, CustomerPhone) c.Leave a copy of the determinant as a foreign key in the original relation. PRESCRIPTION(PrescriptionNumber, Date, Drug, Dosage, CustomerEmail) d.Create a referential integrity constraint between the original relation and the new relation. CustomerEmail in PRESCRIPTION must exist in CustomerEmail in CUSTOMER

8 Normalization Process: Example 1: Step 4 IST2108 Step 4. Repeat step 3 as many times as necessary until every determinant of every relation is a candidate key. CUSTOMER (CustomerEmail, CustomerName, CustomerPhone) PRESCRIPTION(PrescriptionNumber, Date, Drug, Dosage, CustomerEmail) CustomerEmail in PRESCRIPTION must exist in CustomerEmail in CUSTOMER Well-formed relational model design

9 Normalization Process: Exercise 1 IST2109 Step 1. Candidate keys: Step 2. Functional dependencies: Step 3. Determine if the relation is well-formed. If not, split the relation into multiple well-formed relations and specify all the primary keys, foreign keys and referential integrity constraints: Hint: If any determinant is not a candidate key, the relation is not well formed.

10 Normalization Process: Exercise 2 IST21010 Step 1. Candidate keys: Step 2. Functional dependencies: Step 3. Determine if the relation is well-formed. If not, split the relation into multiple well-formed relations and specify all the primary keys, foreign keys and referential integrity constraints: Hint: If any determinant is not a candidate key, the relation is not well formed.

11 Normalization Process: Exercise 3 IST21011 Step 1. Candidate keys Step 2. Functional dependencies GRADE(ClassName, Section, Term, Grade, StudentNumber, StudentName, Professor, ProfessorDepartment, ProfessorEmail) Step 3. Determine if the relation is well-formed. If not, split the relation into multiple well-formed relations and specify all the primary keys, foreign keys and referential integrity constraints: Hint: If any determinant is not a candidate key, the relation is not well formed.

12 Summary of Chapter 2 Learn the concept of the relational model: entities, relations, relationships Learn the meaning and importance of keys, foreign keys, and related terminology Learn the meaning of functional dependencies Learn to apply a process for normalizing relations IST21012

13 True/False Review Questions Given the functional dependency for the attributes of ENTITY1, X → (A, B, C), X is a candidate key for the relation ENTITY1 (A, B, C, X). Normalization is the process of removing all functional dependencies from a relation. In the normalization process, it is not necessary to identify all the functional dependencies in a relation. In the normalization process, if you find a candidate key that is not a primary key, then you have determined that the relation needs to be broken into two or more relations.


Download ppt "Chapter 2. The Relational Model (cont.) IST2101. Review: Determinant vs. Candidate Key IST2102 DeterminantsCandidate Key (StudentID, CourseID) StudentID."

Similar presentations


Ads by Google