Presentation is loading. Please wait.

Presentation is loading. Please wait.

Problems in Designing Schema

Similar presentations


Presentation on theme: "Problems in Designing Schema"— Presentation transcript:

1 Problems in Designing Schema
Name SSN Phone Number Fred (201) Fred (206) Joe (908) Joe (212) Problems: - redundancy - update anomalies - deletion anomalies

2 Relation Decomposition
Break the relation into two relations: Name SSN Fred Joe Name Phone Number Fred (201) Fred (206) Joe (908) Joe (212)

3 Decompositions in General
Let R be a relation with attributes A , A , … A 1 2 n Create two relations R1 and R2 with attributes B , B , … B C , C , … C 1 2 m 1 2 l Such that: B , B , … B C , C , … C = A , A , … A 1 2 m 1 2 l 1 2 n And -- R1 is the projection of R on -- R2 is the projection of R on B , B , … B 1 2 m C , C , … C 1 2 l

4 Boyce-Codd Normal Form
A simple condition for removing anomalies from relations: A relation R is in BCNF if and only if: Whenever there is a nontrivial dependency for R , it is the case that { } a super-key for R. A , A , … A B 1 2 n A , A , … A 1 2 n In English (though a bit vague): Whenever a set of attributes of R is determining another attribute, should determine all the attributes of R.

5 Example Name SSN Phone Number Fred 123-321-99 (201) 555-1234
Joe (908) Joe (212) What are the dependencies? What are the keys? Is it in BCNF?

6 And Now? Name SSN Fred 123-321-99 Joe 909-438-44 Name Phone Number

7 What About This? Name Price Category Gizmo $19.99 gadgets Question:
Find an example of a 2-attribute relation that is not in BCNF.

8 Let’s Decompose! Name Address Move-Date Name Address Name Move-Date

9 More Careful Strategy Find a dependency that violates the BCNF condition: A , A , … A B , B , … B 1 2 n 1 2 m Others A’s B’s R1 R2

10 Example Decomposition
Name Social-security-number Age Eye Color Phone Number Functional dependencies: Name + Social-security-number Age, Eye Color What if we also had an attribute Draft-worthy, and the FD: Age Draft-worthy

11 Decomposition Based on BCNF is Necessarily Correct
Attributes A, B, C FD: A C Relations R1[A,B] R2[A,C] Tuples in R1: (a,b) Tuples in R2: (a,c), (a,d) Tuples in the join of R1 and R2: (a,b,c), (a,b,d) Can (a,b,d) be a bogus tuple?

12 Multivalued Dependencies
Name SSN Phone Number Course Fred (206) CSE-444 Fred (206) CSE-341 Fred (206) CSE-444 Fred (206) CSE-341 The multivalued dependencies are: Name, SSN Phone Number Name, SSN Course 4th Normal form: replace FD by MVD.


Download ppt "Problems in Designing Schema"

Similar presentations


Ads by Google