Download presentation
Presentation is loading. Please wait.
1
Lectures 13: Design Theory II
Professor Xiannong Meng Spring 2018 Lecture and activity contents are based on what Prof Chris Ré used in his CS 145 in the fall 2016 term with permission
2
2. Finding functional dependencies
3
What you will learn about in this section
“Good” vs. “Bad” FDs: Intuition Finding FDs Closures ACTIVITY: Compute the closures
4
“Good” vs. “Bad” FDs We can start to develop a notion of good vs. bad FDs: EmpID Name Phone Position E0045 Smith 1234 Clerk E3542 Mike 9876 Salesrep E1111 E9999 Mary Lawyer Intuitively: EmpID -> Name, Phone, Position is “good FD” Minimal redundancy, less possibility of anomalies
5
“Good” vs. “Bad” FDs We can start to develop a notion of good vs. bad FDs: EmpID Name Phone Position E0045 Smith 1234 Clerk E3542 Mike 9876 Salesrep E1111 E9999 Mary Lawyer Intuitively: EmpID -> Name, Phone, Position is “good FD” But Position -> Phone is a “bad FD” Redundancy! Possibility of data anomalies
6
“Good” vs. “Bad” FDs Given a set of FDs (from user) our goal is to:
Returning to our original example… can you see how the “bad FD” {Course} -> {Room} could lead to an: Update Anomaly Insert Anomaly Delete Anomaly … Student Course Room Mary CS145 B01 Joe Sam .. Given a set of FDs (from user) our goal is to: Find all FDs, and Eliminate the “Bad Ones".
7
FDs for Relational Schema Design
High-level idea: why do we care about FDs? Start with some relational schema Find out its functional dependencies (FDs) Use these to design a better schema One which minimizes possibility of anomalies This part can be tricky!
8
Finding Functional Dependencies
There can be a very large number of FDs… How to find them all efficiently? We can’t necessarily show that any FD will hold on all instances… How to do this? We will start with this problem: Given a set of FDs, F, what other FDs must hold?
9
Finding Functional Dependencies
Equivalent to asking: Given a set of FDs, F = {f1,…fn}, does an FD g hold? Inference problem: How do we decide?
10
Finding Functional Dependencies
Example: Products Provided FDs: Name Color Category Dep Price Gizmo Green Gadget Toys 49 Widget Black 59 Whatsit Garden 99 1. {Name} {Color} 2. {Category} {Department} 3. {Color, Category} {Price} Given the provided FDs, we can see that {Name, Category} {Price} must also hold on any instance… Which / how many other FDs do?!?
11
Finding Functional Dependencies
Equivalent to asking: Given a set of FDs, F = {f1,…fn}, does an FD g hold? Inference problem: How do we decide? Answer: Three simple rules called Armstrong’s Rules. Split/Combine, Reduction, and Transitivity… ideas by picture
12
1. Split/Combine A1 … Am B1 Bn A1, …, Am B1,…,Bn
13
… is equivalent to the following n FDs…
1. Split/Combine A1 … Am B1 Bn A1, …, Am B1,…,Bn … is equivalent to the following n FDs… A1,…,Am Bi for i=1,…,n
14
And vice-versa, A1,…,Am Bi for i=1,…,n
1. Split/Combine A1 … Am B1 Bn And vice-versa, A1,…,Am Bi for i=1,…,n … is equivalent to … A1, …, Am B1,…,Bn
15
2. Reduction/Trivial A1 … Am A1,…,Am Aj for any j=1,…,m
16
3. Transitive Closure A1, …, Am B1,…,Bn and B1,…,Bn C1,…,Ck A1 …
17
3. Transitive Closure A1, …, Am B1,…,Bn and B1,…,Bn C1,…,Ck
implies A1,…,Am C1,…,Ck
18
Finding Functional Dependencies
Example: Products Provided FDs: Name Color Category Dep Price Gizmo Green Gadget Toys 49 Widget Black 59 Whatsit Garden 99 1. {Name} {Color} 2. {Category} {Department} 3. {Color, Category} {Price} Which / how many other FDs hold?
19
Finding Functional Dependencies
Example: Inferred FDs: Provided FDs: Inferred FD Rule used 4. {Name, Category} -> {Name} ? 5. {Name, Category} -> {Color} 6. {Name, Category} -> {Category} 7. {Name, Category -> {Color, Category} 8. {Name, Category} -> {Price} 1. {Name} {Color} 2. {Category} {Dept.} 3. {Color, Category} {Price} Rules: 1. Split/Combine 2. Reduction/Trivial 3. Transitive Closure Which / how many other FDs hold?
20
Finding Functional Dependencies
Example: Inferred FDs: Provided FDs: Inferred FD Rule used 4. {Name, Category} -> {Name} Trivial 5. {Name, Category} -> {Color} Transitive (4 -> 1) 6. {Name, Category} -> {Category} 7. {Name, Category -> {Color, Category} Split/combine (5 + 6) 8. {Name, Category} -> {Price} Transitive (7 -> 3) 1. {Name} {Color} 2. {Category} {Dept.} 3. {Color, Category} {Price} Can we find an algorithmic way to do this?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.