Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 3630 Database Design and Implementation. 2 Functions y = f(x) x1 = x2  f(x1) = f(x2) Same x value, then same function value. Yes, it’s a function!

Similar presentations


Presentation on theme: "CS 3630 Database Design and Implementation. 2 Functions y = f(x) x1 = x2  f(x1) = f(x2) Same x value, then same function value. Yes, it’s a function!"— Presentation transcript:

1 CS 3630 Database Design and Implementation

2 2 Functions y = f(x) x1 = x2  f(x1) = f(x2) Same x value, then same function value. Yes, it’s a function! x1 = x2  f(x1) != f(x2) Same x value, but different function values. No, it’s NOT a function! x1 != x2  f(x1) != f(x2) or f(x1) = f(x2) Different x values, then same or different function values. It’s Good! Still a function!

3 3 Example Staff_and_Branch (Sno, Name, Address, Bno, BAddress) FD: Sno  Name Sno  Address Sno  Bno Sno  Baddress Sno  Name, Address, Bno, Baddress(one FD replacing 4 FDs) Sno  All(one FD replacing 4 FDs) Sno is unique (PK)! SnoNameAddressBnoBAddress S001J. Clifton102 mainB011 westhill S002M. Smith102 mainB023 easttown S013M. Smith20 mainB011 westhill ?????

4 4 Example Staff_and_Branch (Sno, Name, Address, Bno, BAddress) FD: Bno  Baddress Baddress  Bno One branch has one address. One address has one branch. SnoNameAddressBnoBAddress S001J. Clifton102 mainB011 westhill S002M. Smith102 mainB023 easttown S013M. Smith20 mainB011 westhill ?????

5 5 Example Staff_and_Branch (Sno, Name, Address, Bno, BAddress) FD: Name  Sno(False!) Address  Sno(False!) Different staff members (Sno) may have the same name. Different staff members may have the same address. SnoNameAddressBnoBAddress S001J. Clifton102 mainB011 westhill S002M. Smith102 mainB023 easttown S013M. Smith20 mainB011 westhill ?????

6 6 Multiple Variables y = f(x) x  y y = f(x1, x2, x3, x4) x1, x2, x3, x4  y (y1, y2, y3) = f(x) x  y1, y2, y3 (y1, y2, y3) = f(x1, x2, x3, x4) x1, x2, x3, x4  y1, y2, y3

7 7 Functional Dependency Definition In a relation (table) R S: a set of attributes T: a 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!

8 8 Trivial FDs If A, B  X, Y, Z Then A, B  X, Y (trivial)(for any subset of (X, Y, Z)) (reducing on the right side) Do not list A, B  X, Y If the following is true A, B  X, Y, Z

9 9 Trivial FDs If A, B  X, Y, Z Then A, B, C  X, Y, Z (trivial) (adding to the determinant) Do not list A, B, C  X, Y, Z If the following is true A, B  X, Y, Z

10 10 Trivial FDs A, B  X, Y, Z (Do it this way) The above FD is equivalent to the following three FDs: A, B  X A, B  Y A, B  Z A, B, C  A, B, C (trivial) A, B, C  A, C (trivial) A, B, C  All (other attributes) (Do it this way when true)

11 11 Example Assumptions No multi-value attribute Pno and PAddress 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 rents. 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:

12 12 Candidate Keys and FDs For any attribute X of a table Candidate Key  X PK  X AK  X 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 trival)

13 13 Partial FDs If X, W  Y and X  Y Then X, W  Y is trivial and a partial FD Example: Sno, Bno  Address, Phone Partial? Yes! Sno  Address, Phone

14 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 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!)

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

17 17 Transitive FDs 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! ABC

18 Assignment 5-1 Due Wednesday, February 25 18

19 Quiz 1 19


Download ppt "CS 3630 Database Design and Implementation. 2 Functions y = f(x) x1 = x2  f(x1) = f(x2) Same x value, then same function value. Yes, it’s a function!"

Similar presentations


Ads by Google