Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 3630 Database Design and Implementation

Similar presentations


Presentation on theme: "CS 3630 Database Design and Implementation"— Presentation transcript:

1 CS 3630 Database Design and Implementation

2 Functional Dependency
Definition Assume A and B are attributes of a table R. A  B (B is functionally dependent on A) If each value of A in R is associated with exactly one value of B in R. A is called Determinant. Any two records of R If they agree on A (have the same value on A), Then they will agree on B (have the same value on B). If they have different values on A, Then they may have different values or the same value on B. B = f(A)

3 Functional Dependency
Definition In a relation (table) R S: a non-empty set of attributes T: a non-empty set of attributes S  T For ANY relation (table) instance If two records of R have the same values on S Then they will have the same values on T. S is called the determinant. Each value of S is associated with exactly one value of T. T = f(S) Different values of S, we do not care! It’s good! Could skip slide #2

4 A1, A2, A3  B1, B2, B3, B4 Viewing (Cno, Pno, ViewDate, ViewTime, Comment) Cno, ViewDate, ViewTime  Pno, Comment Cno, ViewDate, ViewTime  All Cno, ViewDate  All Cno, ViewTime  All ViewDate, ViewTime  All True False

5 A1, A2, A3  B1, B2, B3, B4 Viewing (Cno, Pno, ViewDate, ViewTime, Comment) Cno, ViewDate, ViewTime  All Pno, ViewDate  All Cno, Pno, ViewDate  All True False

6 Trivial FDs If A, B  X, Y, Z Then the following are trivial
A, B, C  X, Y, Z Reducing on the right side or Adding to the left side (the determinant)

7 Non-Trivial FDs A, B  X, Y, Z
Minimum set of attributes on the left for the determinant Maximum set of attributes on the right Do not list A, B, C  X, Y, Z A, B  X, Y If the following is true

8 DreamHome Assumptions No multi-value attribute
Pno identifies property unit (house, apartment, room) for renting PAddress also identifies property unit (house, apartment, room) for renting A property can only be leased out once at a given time, but may have many leases for different times with different details. When a group of people rent one property together, there will be only one lease with one renter from the group Lease (Rno, Rname, Pno, PAddress, Rent, Start, Finish, Ono, OName) List all non-trivial FDs: Primary Key: Alternate Keys: Each student gives one answer The table keeps all records, past, current, and future

9 List all non-trivial FDs
Lease (Rno, Rname, Pno, PAddress, Rent, Start, Finish, Ono, OName) Pno  All Rno  All Pno, Start  All Rno, Start  All Pno, Finish  All PAddress, Start  All Paddress, Finish  All Each student gives one answer The table keeps all records, past, current, and future

10 List all non-trivial FDs
Lease (Rno, Rname, Pno, PAddress, Rent, Start, Finish, Ono, OName) Pno  ? Rno  ? Rname  ? Rno, Start  ? Ono  ? Oname  ? PAddress  ? Each student gives one answer The table keeps all records, past, current, and future

11 Keys Candidate Key? A minimum set of attributes that uniquely identifies each occurrence of an entity type. No proper subset satisfying the definition. Not minimum cardinality. Primary Key The candidate key that is selected to uniquely identify each occurrence of an entity type (table/relation). Alternate Key Candidate key that is not selected as the primary key still unique

12 Candidate Keys and FDs For all other attributes of a table
Candidate Key  All PK  All AK All Candidate key uniquely identifies tables records. Any two different records must have different values for the candidate key. If S is a candidate key, then S  All If S  All, then S is a candidate key (if S is minimum: S  All is not trivial)

13 Partial FDs X, W  Y is partial if X  Y or W  Y
Special case of trivial FD Example: Sno, Bno  Address, Phone Partial? Yes! Sno  Address, Phone

14 Full FDs A FD is a full FD if it’s not partial.
A, B  X, Y is a full FD if A X, Y is false B  X, Y is false Sno  Address, Phone Pno, Start  Rno, Rent, End

15 Transitive FDs If A  B and B  C Then A  C is always TRUE
(provided A is not functionally dependent on either B or C) (NO cycle!) A  B B  C A  C (you can have this one on A51)

16 Transitive FDs A B C If A  B and B  C Then A  C

17 Transitive FDs A B C If A  B and B  C Then A C
Provided not B  A (A and B are equivalent) nor C  A (A, B and C are equivalent) No Cycle!

18 Due Friday, February 23 At 5 PM
Assignment 5-1 Due Friday, February 23 At 5 PM Could discuss Assignment 4


Download ppt "CS 3630 Database Design and Implementation"

Similar presentations


Ads by Google