SlideShare a Scribd company logo
1 of 22
Functional Dependencies
Definition:
If two tuples agree on the attributes
A , A , … A
1 2 n
then they must also agree on the attributes
B , B , … B
1 2 m
Formally:
A , A , … A
1 2 n
B , B , … B
1 2 m
Motivating example for the study of functional dependencies:
Name Social Security Number Phone Number
Examples
Product: name price, manufacturer
Person: ssn name, age
Company: name stock price, president
Key of a relation is a set of attributes that:
- functionally determines all the attributes of the relation
- none of its subsets determines all the attributes.
Superkey: a set of attributes that contains a key.
Finding the Attributes of a
Relation
Given a relation constructed from an E/R diagram, what is its key?
Rules:
1. If the relation comes from an entity set,
the key of the relation is the set of attributes which is the
key of the entity set.
address name ssn
Person
Rules for Binary Relationships
Several cases are possible for a binary relationship E1 - E2:
1. Many-many: the key includes the key of E1 together with the
key of E2.
What happens for:
2. Many-one:
3. One-one:
Person
buys
Product
name
price name ssn
Rules for Multiway Relationships
None, really.
Except: if there is an arrow from the relationship to E, then
we don’t need the key of E as part of the relation key.
Purchase
Product
Person
Store
Payment Method
Some Properties of FD’s
A , A , … A
1 2 n
B , B , … B
1 2 m
A , A , … A
1 2 n 1
Is equivalent to
B
A , A , … A
1 2 n 2
B
A , A , … A
1 2 n m
B
…
A , A , … A
1 2 n i
A Always holds.
Splitting rule
and
Combing rule
Comparing Functional
Dependencies
Functional dependencies: a statement about the set of allowable
databases.
Entailment and equivalence: comparing sets of functional dependencies
Entailment: a set of functional dependencies S1 entails a set S2 if:
any database that satisfies S1 much also satisfy S2.
Example: {A B, B C}
entails
A C
Equivalence: two sets of FD’s are equivalent if each entails the
other.
{A B, B C } is equivalent to {A B, A C, B C}
Closure of a set of Attributes
Given a set of attributes A and a set of dependencies C,
we want to find all the other attributes that are functionally
determined by A.
In other words, we want to find the maximal set of attributes B,
such that for every B in B,
C entails A B.
Closure Algorithm
Start with Closure=A.
Until closure doesn’t change do:
if is in C, and
B is not in Closure
then
add B to closure.
A , A , … A
1 2 n
B
A , A , … A
1 2 n
are all in the closure, and
Example
A B C
A D E
B D
A F B
Closure of {A,B}:
Closure of {A, F}:
Problems in Designing Schema
Name SSN Phone Number
Fred 123-321-99 (201) 555-1234
Fred 123-321-99 (206) 572-4312
Joe 909-438-44 (908) 464-0028
Joe 909-438-44 (212) 555-4000
Problems:
- redundancy
- update anomalies
- deletion anomalies
Relation Decomposition
Name SSN
Fred 123-321-99
Joe 909-438-44
Name Phone Number
Fred (201) 555-1234
Fred (206) 572-4312
Joe (908) 464-0028
Joe (212) 555-4000
Break the relation into two relations:
Decompositions in General
A , A , … A
1 2 n
Let R be a relation with attributes
Create two relations R1 and R2 with attributes
B , B , … B
1 2 m
C , C , … C
1 2 l
Such that:
B , B , … B
1 2 m
C , C , … C
1 2 l
 = A , A , … A
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
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
1 2 n
B
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.
Example
Name SSN Phone Number
Fred 123-321-99 (201) 555-1234
Fred 123-321-99 (206) 572-4312
Joe 909-438-44 (908) 464-0028
Joe 909-438-44 (212) 555-4000
What are the dependencies?
What are the keys?
Is it in BCNF?
And Now?
SSN Name
123-321-99 Fred
909-438-44 Joe
SSN Phone Number
123-321-99 (201) 555-1234
123-321-99 (206) 572-4312
909-438-44 (908) 464-0028
909-438-44 (212) 555-4000
What About This?
Name Price Category
Gizmo $19.99 gadgets
Question:
Find an example of a 2-attribute relation that is not in BCNF.
More Decompositions
Name Address Move-Date
Name Address
Name Move-Date
What’s wrong?
More Careful Strategy
Find a dependency that violates the BCNF condition:
A , A , … A
1 2 n
B , B , … B
1 2 m
A’s
Others B’s
R1 R2
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
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?
Multivalued Dependencies
Name SSN Phone Number Course
Fred 123-321-99 (206) 572-4312 CSE-444
Fred 123-321-99 (206) 572-4312 CSE-341
Fred 123-321-99 (206) 432-8954 CSE-444
Fred 123-321-99 (206) 432-8954 CSE-341
The multivalued dependencies are:
Name, SSN Phone Number
Name, SSN Course
4th Normal form: replace FD by MVD.

More Related Content

Similar to fds.ppt (20)

7. Relational Database Design in DBMS
7. Relational Database Design in DBMS7. Relational Database Design in DBMS
7. Relational Database Design in DBMS
 
Mca ii-dbms- u-iii-sql concepts
Mca ii-dbms- u-iii-sql conceptsMca ii-dbms- u-iii-sql concepts
Mca ii-dbms- u-iii-sql concepts
 
Relational+algebra (1)
Relational+algebra (1)Relational+algebra (1)
Relational+algebra (1)
 
L8 design1
L8 design1L8 design1
L8 design1
 
UNIT 2 -PPT.pptx
UNIT 2 -PPT.pptxUNIT 2 -PPT.pptx
UNIT 2 -PPT.pptx
 
Normalization1
Normalization1Normalization1
Normalization1
 
DBMS-Normalization.ppt
DBMS-Normalization.pptDBMS-Normalization.ppt
DBMS-Normalization.ppt
 
Fd & Normalization - Database Management System
Fd & Normalization - Database Management SystemFd & Normalization - Database Management System
Fd & Normalization - Database Management System
 
Cs501 fd nf
Cs501 fd nfCs501 fd nf
Cs501 fd nf
 
Bsc cs ii-dbms- u-iii-data modeling using e.r. model (entity relationship model)
Bsc cs ii-dbms- u-iii-data modeling using e.r. model (entity relationship model)Bsc cs ii-dbms- u-iii-data modeling using e.r. model (entity relationship model)
Bsc cs ii-dbms- u-iii-data modeling using e.r. model (entity relationship model)
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
 
Database Design and Normalization Techniques
Database Design and Normalization TechniquesDatabase Design and Normalization Techniques
Database Design and Normalization Techniques
 
lecture2.ppt
lecture2.pptlecture2.ppt
lecture2.ppt
 
lecture2.ppt
lecture2.pptlecture2.ppt
lecture2.ppt
 
18560 lecture6
18560 lecture618560 lecture6
18560 lecture6
 
ch2
ch2ch2
ch2
 
Chapter0
Chapter0Chapter0
Chapter0
 
3 summary
3 summary3 summary
3 summary
 
test
testtest
test
 
Database Management System [DBMS]
Database Management System [DBMS]Database Management System [DBMS]
Database Management System [DBMS]
 

Recently uploaded

TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptxPoojaSen20
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...EADTU
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...Nguyen Thanh Tu Collection
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文中 央社
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...Nguyen Thanh Tu Collection
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint23600690
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportDenish Jangid
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnershipsexpandedwebsite
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMELOISARIVERA8
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjMohammed Sikander
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...EduSkills OECD
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppCeline George
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....Ritu480198
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptxVishal Singh
 

Recently uploaded (20)

TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptx
 

fds.ppt

  • 1. Functional Dependencies Definition: If two tuples agree on the attributes A , A , … A 1 2 n then they must also agree on the attributes B , B , … B 1 2 m Formally: A , A , … A 1 2 n B , B , … B 1 2 m Motivating example for the study of functional dependencies: Name Social Security Number Phone Number
  • 2. Examples Product: name price, manufacturer Person: ssn name, age Company: name stock price, president Key of a relation is a set of attributes that: - functionally determines all the attributes of the relation - none of its subsets determines all the attributes. Superkey: a set of attributes that contains a key.
  • 3. Finding the Attributes of a Relation Given a relation constructed from an E/R diagram, what is its key? Rules: 1. If the relation comes from an entity set, the key of the relation is the set of attributes which is the key of the entity set. address name ssn Person
  • 4. Rules for Binary Relationships Several cases are possible for a binary relationship E1 - E2: 1. Many-many: the key includes the key of E1 together with the key of E2. What happens for: 2. Many-one: 3. One-one: Person buys Product name price name ssn
  • 5. Rules for Multiway Relationships None, really. Except: if there is an arrow from the relationship to E, then we don’t need the key of E as part of the relation key. Purchase Product Person Store Payment Method
  • 6. Some Properties of FD’s A , A , … A 1 2 n B , B , … B 1 2 m A , A , … A 1 2 n 1 Is equivalent to B A , A , … A 1 2 n 2 B A , A , … A 1 2 n m B … A , A , … A 1 2 n i A Always holds. Splitting rule and Combing rule
  • 7. Comparing Functional Dependencies Functional dependencies: a statement about the set of allowable databases. Entailment and equivalence: comparing sets of functional dependencies Entailment: a set of functional dependencies S1 entails a set S2 if: any database that satisfies S1 much also satisfy S2. Example: {A B, B C} entails A C Equivalence: two sets of FD’s are equivalent if each entails the other. {A B, B C } is equivalent to {A B, A C, B C}
  • 8. Closure of a set of Attributes Given a set of attributes A and a set of dependencies C, we want to find all the other attributes that are functionally determined by A. In other words, we want to find the maximal set of attributes B, such that for every B in B, C entails A B.
  • 9. Closure Algorithm Start with Closure=A. Until closure doesn’t change do: if is in C, and B is not in Closure then add B to closure. A , A , … A 1 2 n B A , A , … A 1 2 n are all in the closure, and
  • 10. Example A B C A D E B D A F B Closure of {A,B}: Closure of {A, F}:
  • 11. Problems in Designing Schema Name SSN Phone Number Fred 123-321-99 (201) 555-1234 Fred 123-321-99 (206) 572-4312 Joe 909-438-44 (908) 464-0028 Joe 909-438-44 (212) 555-4000 Problems: - redundancy - update anomalies - deletion anomalies
  • 12. Relation Decomposition Name SSN Fred 123-321-99 Joe 909-438-44 Name Phone Number Fred (201) 555-1234 Fred (206) 572-4312 Joe (908) 464-0028 Joe (212) 555-4000 Break the relation into two relations:
  • 13. Decompositions in General A , A , … A 1 2 n Let R be a relation with attributes Create two relations R1 and R2 with attributes B , B , … B 1 2 m C , C , … C 1 2 l Such that: B , B , … B 1 2 m C , C , … C 1 2 l  = A , A , … A 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
  • 14. 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 1 2 n B 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.
  • 15. Example Name SSN Phone Number Fred 123-321-99 (201) 555-1234 Fred 123-321-99 (206) 572-4312 Joe 909-438-44 (908) 464-0028 Joe 909-438-44 (212) 555-4000 What are the dependencies? What are the keys? Is it in BCNF?
  • 16. And Now? SSN Name 123-321-99 Fred 909-438-44 Joe SSN Phone Number 123-321-99 (201) 555-1234 123-321-99 (206) 572-4312 909-438-44 (908) 464-0028 909-438-44 (212) 555-4000
  • 17. What About This? Name Price Category Gizmo $19.99 gadgets Question: Find an example of a 2-attribute relation that is not in BCNF.
  • 18. More Decompositions Name Address Move-Date Name Address Name Move-Date What’s wrong?
  • 19. More Careful Strategy Find a dependency that violates the BCNF condition: A , A , … A 1 2 n B , B , … B 1 2 m A’s Others B’s R1 R2
  • 20. 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
  • 21. 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?
  • 22. Multivalued Dependencies Name SSN Phone Number Course Fred 123-321-99 (206) 572-4312 CSE-444 Fred 123-321-99 (206) 572-4312 CSE-341 Fred 123-321-99 (206) 432-8954 CSE-444 Fred 123-321-99 (206) 432-8954 CSE-341 The multivalued dependencies are: Name, SSN Phone Number Name, SSN Course 4th Normal form: replace FD by MVD.