Sunteți pe pagina 1din 115

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Functional Dependencies
T. M. Murali

October 18, 25, 2010

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Midterm Review

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Midterm Review
The database server set up is driving me NUTS!

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Midterm Review
The database server set up is driving me NUTS! The class is slow (no 3NF yet). Why are we doing design before learning normalisation? It seems odd to teach relational models after SQL.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Midterm Review
The database server set up is driving me NUTS! The class is slow (no 3NF yet). Why are we doing design before learning normalisation? It seems odd to teach relational models after SQL. Homework grading is strict/uneven.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Midterm Review
The database server set up is driving me NUTS! The class is slow (no 3NF yet). Why are we doing design before learning normalisation? It seems odd to teach relational models after SQL. Homework grading is strict/uneven. Increase amount of examples/hands-on work.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Midterm Review
The database server set up is driving me NUTS! The class is slow (no 3NF yet). Why are we doing design before learning normalisation? It seems odd to teach relational models after SQL. Homework grading is strict/uneven. Increase amount of examples/hands-on work. Make the lectures more interactive.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Midterm Review
The database server set up is driving me NUTS! The class is slow (no 3NF yet). Why are we doing design before learning normalisation? It seems odd to teach relational models after SQL. Homework grading is strict/uneven. Increase amount of examples/hands-on work. Make the lectures more interactive. Oce hours change a lot.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Midterm Review
The database server set up is driving me NUTS! The class is slow (no 3NF yet). Why are we doing design before learning normalisation? It seems odd to teach relational models after SQL. Homework grading is strict/uneven. Increase amount of examples/hands-on work. Make the lectures more interactive. Oce hours change a lot. Wish the project was free form.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Midterm Review
The database server set up is driving me NUTS! The class is slow (no 3NF yet). Why are we doing design before learning normalisation? It seems odd to teach relational models after SQL. Homework grading is strict/uneven. Increase amount of examples/hands-on work. Make the lectures more interactive. Oce hours change a lot. Wish the project was free form. It would be nice to have a table of RA symbols and E/R diagram shapes.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Example
Name Id Name Id

Students

Advises

Advisors

Favourite

Convert to relations:

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Example
Name Id Name Id

Students

Advises

Advisors

Favourite

Convert to relations: Students(Id, Name) Advisors(Id, Name) Advises(StudentId, AdvisorId) Favourite(StudentId, AdvisorId)

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Example
Name Id Name Id

Students

Advises

Advisors

Favourite

Convert to relations: Students(Id, Name) Advisors(Id, Name) Advises(StudentId, AdvisorId) Favourite(StudentId, AdvisorId) Suppose we perversely decide to convert Students, Advises, and Favourite into one relation. Students(Id, Name, AdvisorId, AdvisorName, FavouriteAdvisorId)
T. M. Murali October 18, 25, 2010 CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Example of a Bad Relation


Students(Id, Name, AdvisorId, AdvisorName, FavouriteAdvisorId) If you know a students Id, can you determine the values of any other attributes?

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Example of a Bad Relation


Students(Id, Name, AdvisorId, AdvisorName, FavouriteAdvisorId) If you know a students Id, can you determine the values of any other attributes? Name and FavouriteAdvisorId.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Example of a Bad Relation


Students(Id, Name, AdvisorId, AdvisorName, FavouriteAdvisorId) If you know a students Id, can you determine the values of any other attributes? Name and FavouriteAdvisorId. Id Name Id FavouriteAdvisorId

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Example of a Bad Relation


Students(Id, Name, AdvisorId, AdvisorName, FavouriteAdvisorId) If you know a students Id, can you determine the values of any other attributes? Name and FavouriteAdvisorId. Id Name Id FavouriteAdvisorId AdvisorId

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Example of a Bad Relation


Students(Id, Name, AdvisorId, AdvisorName, FavouriteAdvisorId) If you know a students Id, can you determine the values of any other attributes? Name and FavouriteAdvisorId. Id Name Id FavouriteAdvisorId AdvisorId AdvisorName

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Example of a Bad Relation


Students(Id, Name, AdvisorId, AdvisorName, FavouriteAdvisorId) If you know a students Id, can you determine the values of any other attributes? Name and FavouriteAdvisorId. Id Name Id FavouriteAdvisorId AdvisorId AdvisorName Can we say Id AdvisorId?

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Example of a Bad Relation


Students(Id, Name, AdvisorId, AdvisorName, FavouriteAdvisorId) If you know a students Id, can you determine the values of any other attributes? Name and FavouriteAdvisorId. Id Name Id FavouriteAdvisorId AdvisorId AdvisorName Can we say Id AdvisorId? NO! Id is not a key for the Students relation.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Example of a Bad Relation


Students(Id, Name, AdvisorId, AdvisorName, FavouriteAdvisorId) If you know a students Id, can you determine the values of any other attributes? Name and FavouriteAdvisorId. Id Name Id FavouriteAdvisorId AdvisorId AdvisorName Can we say Id AdvisorId? NO! Id is not a key for the Students relation. What is the key for the Students?

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Example of a Bad Relation


Students(Id, Name, AdvisorId, AdvisorName, FavouriteAdvisorId) If you know a students Id, can you determine the values of any other attributes? Name and FavouriteAdvisorId. Id Name Id FavouriteAdvisorId AdvisorId AdvisorName Can we say Id AdvisorId? NO! Id is not a key for the Students relation. What is the key for the Students? {Id, AdvisorId}.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Example of a Bad Relation


Students(Id, Name, AdvisorId, AdvisorName, FavouriteAdvisorId) If you know a students Id, can you determine the values of any other attributes? Name and FavouriteAdvisorId. Id Name Id FavouriteAdvisorId AdvisorId AdvisorName Can we say Id AdvisorId? NO! Id is not a key for the Students relation. What is the key for the Students? {Id, AdvisorId}. Why is this relation bad?

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Example of a Bad Relation


Students(Id, Name, AdvisorId, AdvisorName, FavouriteAdvisorId) If you know a students Id, can you determine the values of any other attributes? Name and FavouriteAdvisorId. Id Name Id FavouriteAdvisorId AdvisorId AdvisorName Can we say Id AdvisorId? NO! Id is not a key for the Students relation. What is the key for the Students? {Id, AdvisorId}. Why is this relation bad? Parts of the key determine other attributes.
T. M. Murali October 18, 25, 2010 CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Motivation for Functional Dependencies

Reason about constraints on attributes in a relation. Procedurally determine the keys of a relation. Detect when a relation has redundant information. Improve database designs systematically using normalisation.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Denition of Functional Dependency

If t is a tuple in a relation R and A is an attribute of R , then tA is the value of attribute A in tuple t .

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Denition of Functional Dependency

If t is a tuple in a relation R and A is an attribute of R , then tA is the value of attribute A in tuple t . The FD AdvisorId AdvisorName holds in R if in every instance of R , for every pair of tuples t and u

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Denition of Functional Dependency

If t is a tuple in a relation R and A is an attribute of R , then tA is the value of attribute A in tuple t . The FD AdvisorId AdvisorName holds in R if in every instance of R , for every pair of tuples t and u if tAdvisorId = uAdvisorId , then tAdvisorName = uAdvisorName .

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Denition of Functional Dependencies


A functional dependency (FD) on a relation R is a statement If two tuples in R agree on attributes A1 , A2 , . . . An then they agree on attribute B . Notation: A1 A2 . . . An B

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Denition of Functional Dependencies


A functional dependency (FD) on a relation R is a statement If two tuples in R agree on attributes A1 , A2 , . . . An then they agree on attribute B . Notation: A1 A2 . . . An B FD says that for every pair of tuples t and u in any instance of R ,

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Denition of Functional Dependencies


A functional dependency (FD) on a relation R is a statement If two tuples in R agree on attributes A1 , A2 , . . . An then they agree on attribute B . Notation: A1 A2 . . . An B FD says that for every pair of tuples t and u in any instance of R , if tA1 = uA1 and tA2 = uA2 and . . . tAn = uAn , then tB = uB . The set of attributes A1 , A2 , . . . An functionally determine B . An FD is a constraint on a single relation schema. It must hold on every instance of the relation. You cannot deduce an FD from a relation instance.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Examples of FDs
What FDs can we assert for the relation
Courses(Number, DeptName, CourseName, Classroom, Enrollment) Number 4604 4604 4604 2604 2604 DeptName CS Dance English CS Physics CourseName Databases Tree Dancing The Basis of Data Data Structures Dark Matter Classroom TORG 1020 Drilleld Williams 44 MCB 114 Williams 44 Enrollment 45 45 45 100 100

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Examples of FDs
What FDs can we assert for the relation
Courses(Number, DeptName, CourseName, Classroom, Enrollment) Number 4604 4604 4604 2604 2604 DeptName CS Dance English CS Physics CourseName Databases Tree Dancing The Basis of Data Data Structures Dark Matter Classroom TORG 1020 Drilleld Williams 44 MCB 114 Williams 44 Enrollment 45 45 45 100 100

Number DeptName CourseName Number DeptName Classroom Number DeptName Enrollment

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Examples of FDs
What FDs can we assert for the relation
Courses(Number, DeptName, CourseName, Classroom, Enrollment) Number 4604 4604 4604 2604 2604 DeptName CS Dance English CS Physics CourseName Databases Tree Dancing The Basis of Data Data Structures Dark Matter Classroom TORG 1020 Drilleld Williams 44 MCB 114 Williams 44 Enrollment 45 45 45 100 100

Number Number Number Number


T. M. Murali

DeptName CourseName DeptName Classroom DeptName Enrollment DeptName CourseName Classroom Enrollment
October 18, 25, 2010 CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Examples of FDs
What FDs can we assert for the relation
Courses(Number, DeptName, CourseName, Classroom, Enrollment) Number 4604 4604 4604 2604 2604 DeptName CS Dance English CS Physics CourseName Databases Tree Dancing The Basis of Data Data Structures Dark Matter Classroom TORG 1020 Drilleld Williams 44 MCB 114 Williams 44 Enrollment 45 45 45 100 100

Number DeptName CourseName Number DeptName Classroom Number DeptName Enrollment Number DeptName CourseName Classroom Enrollment Is Number Enrollment an FD?
T. M. Murali October 18, 25, 2010 CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Where do FDs come from?

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Where do FDs come from?

Keyness of attributes. Domain and application constraints. Real world constraints, e.g., ProfessorID Time Classroom

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Denition of Keys
FDs allow us to formally dene keys. A set of attributes {A1 , A2 , . . . An } is a key for a relation R if Uniqueness {A1 , A2 , . . . An } functionally determine all the other attributes of R and Minimality no proper subset of {A1 , A2 , . . . An } functionally determines all the other attributes of R .

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Denition of Keys
FDs allow us to formally dene keys. A set of attributes {A1 , A2 , . . . An } is a key for a relation R if Uniqueness {A1 , A2 , . . . An } functionally determine all the other attributes of R and Minimality no proper subset of {A1 , A2 , . . . An } functionally determines all the other attributes of R . A superkey is a set of attributes that has the uniqueness property but is not necessarily minimal. If a relation has multiple keys, specify one to be the primary key. Convention: in a relational schema, underline the attributes of the primary key. If a key has only one attribute A, we say that A rather than {A} is a key.
T. M. Murali October 18, 25, 2010 CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Example of Keys

What is the key for Courses(Number, DeptName, CourseName, Classroom, Enrollment)?

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Example of Keys

What is the key for Courses(Number, DeptName, CourseName, Classroom, Enrollment)? The key is {Number, DeptName}.
These attributes functionally determine every other attribute. No proper subset of {Number, DeptName} has this property.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Example of Keys
What is the key for Courses(Number, DeptName, CourseName, Classroom, Enrollment)? The key is {Number, DeptName}.
These attributes functionally determine every other attribute. No proper subset of {Number, DeptName} has this property.

What is the key for Teach(Number, DepartmentName, ProfessorName, Classroom)?

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Example of Keys
What is the key for Courses(Number, DeptName, CourseName, Classroom, Enrollment)? The key is {Number, DeptName}.
These attributes functionally determine every other attribute. No proper subset of {Number, DeptName} has this property.

What is the key for Teach(Number, DepartmentName, ProfessorName, Classroom)? The key is {Number, DepartmentName}. Why?

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Keys in the Conversion from E/R to Relational Designs


If the relation comes from an entity set, the key attributes of the relation are precisely the key attributes of the entity set.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Keys in the Conversion from E/R to Relational Designs


If the relation comes from an entity set, the key attributes of the relation are precisely the key attributes of the entity set. If the relation comes from a binary relationship R between entity sets E and F :

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Keys in the Conversion from E/R to Relational Designs


If the relation comes from an entity set, the key attributes of the relation are precisely the key attributes of the entity set. If the relation comes from a binary relationship R between entity sets E and F :
R is many-many:

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Keys in the Conversion from E/R to Relational Designs


If the relation comes from an entity set, the key attributes of the relation are precisely the key attributes of the entity set. If the relation comes from a binary relationship R between entity sets E and F :
R is many-many: key attributes of the relation are the key attributes of E and of F .

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Keys in the Conversion from E/R to Relational Designs


If the relation comes from an entity set, the key attributes of the relation are precisely the key attributes of the entity set. If the relation comes from a binary relationship R between entity sets E and F :
R is many-many: key attributes of the relation are the key attributes of E and of F . R is many-one from E to F :

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Keys in the Conversion from E/R to Relational Designs


If the relation comes from an entity set, the key attributes of the relation are precisely the key attributes of the entity set. If the relation comes from a binary relationship R between entity sets E and F :
R is many-many: key attributes of the relation are the key attributes of E and of F . R is many-one from E to F : key attributes of the relation are the key attributes of E .

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Keys in the Conversion from E/R to Relational Designs


If the relation comes from an entity set, the key attributes of the relation are precisely the key attributes of the entity set. If the relation comes from a binary relationship R between entity sets E and F :
R is many-many: key attributes of the relation are the key attributes of E and of F . R is many-one from E to F : key attributes of the relation are the key attributes of E . R is one-one:

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Keys in the Conversion from E/R to Relational Designs


If the relation comes from an entity set, the key attributes of the relation are precisely the key attributes of the entity set. If the relation comes from a binary relationship R between entity sets E and F :
R is many-many: key attributes of the relation are the key attributes of E and of F . R is many-one from E to F : key attributes of the relation are the key attributes of E . R is one-one: key attributes of the relation are the key attributes of E or of F .

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Keys in the Conversion from E/R to Relational Designs


If the relation comes from an entity set, the key attributes of the relation are precisely the key attributes of the entity set. If the relation comes from a binary relationship R between entity sets E and F :
R is many-many: key attributes of the relation are the key attributes of E and of F . R is many-one from E to F : key attributes of the relation are the key attributes of E . R is one-one: key attributes of the relation are the key attributes of E or of F .

If the relationship R is multiway

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Keys in the Conversion from E/R to Relational Designs


If the relation comes from an entity set, the key attributes of the relation are precisely the key attributes of the entity set. If the relation comes from a binary relationship R between entity sets E and F :
R is many-many: key attributes of the relation are the key attributes of E and of F . R is many-one from E to F : key attributes of the relation are the key attributes of E . R is one-one: key attributes of the relation are the key attributes of E or of F .

If the relationship R is multiway, we need to reason about the FDs that R satises.
There is no simple rule. If R has an arrow towards entity set E , at least one key for the relation for R excludes the key for E .
T. M. Murali October 18, 25, 2010 CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Rules for Manipulating FDs

Learn how to reason about FDs. Dene rules for deriving new FDs from a given set of FDs. Next class: use these rules to remove anomalies from relational designs.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Rules for Manipulating FDs

Learn how to reason about FDs. Dene rules for deriving new FDs from a given set of FDs. Next class: use these rules to remove anomalies from relational designs. Example: A relation R with attributes A, B , and C , satises the FDs A B and B C . What other FDs does it satisfy?

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Rules for Manipulating FDs

Learn how to reason about FDs. Dene rules for deriving new FDs from a given set of FDs. Next class: use these rules to remove anomalies from relational designs. Example: A relation R with attributes A, B , and C , satises the FDs A B and B C . What other FDs does it satisfy? A C .

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Rules for Manipulating FDs

Learn how to reason about FDs. Dene rules for deriving new FDs from a given set of FDs. Next class: use these rules to remove anomalies from relational designs. Example: A relation R with attributes A, B , and C , satises the FDs A B and B C . What other FDs does it satisfy? A C . What is the key for R ?

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Rules for Manipulating FDs

Learn how to reason about FDs. Dene rules for deriving new FDs from a given set of FDs. Next class: use these rules to remove anomalies from relational designs. Example: A relation R with attributes A, B , and C , satises the FDs A B and B C . What other FDs does it satisfy? A C . What is the key for R ? A, because A B and A C .

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Equivalence of FDs

An FD F follows from a set of FDs T if every relation instance that satises all the FDs in T also satises F .
A C follows from T = {A B , B C }. Does T follow from S ?

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Equivalence of FDs

An FD F follows from a set of FDs T if every relation instance that satises all the FDs in T also satises F .
A C follows from T = {A B , B C }. Does T follow from S ?

Two sets of FDs S and T are equivalent if each FD in S follows from T and each FD in T follows from S .
S = {A B , B C , A C } and T = {A B , B C } are equivalent.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Equivalence of FDs

An FD F follows from a set of FDs T if every relation instance that satises all the FDs in T also satises F .
A C follows from T = {A B , B C }. Does T follow from S ?

Two sets of FDs S and T are equivalent if each FD in S follows from T and each FD in T follows from S .
S = {A B , B C , A C } and T = {A B , B C } are equivalent.

These notions are useful in deriving new FDs from a given set of FDs.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Splitting and Combining FDs


The set of FDs A1 A2 . . . An B1 A1 A2 . . . An B2 . . . A1 A2 . . . An Bm is equivalent to the FD A1 A2 . . . An B1 B2 . . . Bm . This equivalence implies two rules.
Splitting rule Combining rule These rules work because all the FDs in S and T have identical left hand sides.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Splitting and Combining FDs

Can we split and combine left hand sides of FDs?

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Splitting and Combining FDs

Can we split and combine left hand sides of FDs? For the relation Courses, is the FD Number DeptName CourseName equivalent to the set of FDs {Number CourseName, DeptName CourseName}?

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Splitting and Combining FDs

Can we split and combine left hand sides of FDs? For the relation Courses, is the FD Number DeptName CourseName equivalent to the set of FDs {Number CourseName, DeptName CourseName}? NO!

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Triviality of FDs
An FD A1 A2 . . . An B1 B2 . . . Bm is

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Triviality of FDs
An FD A1 A2 . . . An B1 B2 . . . Bm is trivial if the B s are a subset of the As,

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Triviality of FDs
An FD A1 A2 . . . An B1 B2 . . . Bm is trivial if the B s are a subset of the As, i.e., {B1 , B2 , . . . Bn } {A1 , A2 , . . . An }.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Triviality of FDs
An FD A1 A2 . . . An B1 B2 . . . Bm is trivial if the B s are a subset of the As, i.e., {B1 , B2 , . . . Bn } {A1 , A2 , . . . An }. non-trivial if at least one B is not among the As,

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Triviality of FDs
An FD A1 A2 . . . An B1 B2 . . . Bm is trivial if the B s are a subset of the As, i.e., {B1 , B2 , . . . Bn } {A1 , A2 , . . . An }. non-trivial if at least one B is not among the As, i.e., {B1 , B2 , . . . Bn } {A1 , A2 , . . . An } = .

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Triviality of FDs
An FD A1 A2 . . . An B1 B2 . . . Bm is trivial if the B s are a subset of the As, i.e., {B1 , B2 , . . . Bn } {A1 , A2 , . . . An }. non-trivial if at least one B is not among the As, i.e., {B1 , B2 , . . . Bn } {A1 , A2 , . . . An } = . completely non-trivial if none of the B s are among the As,

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Triviality of FDs
An FD A1 A2 . . . An B1 B2 . . . Bm is trivial if the B s are a subset of the As, i.e., {B1 , B2 , . . . Bn } {A1 , A2 , . . . An }. non-trivial if at least one B is not among the As, i.e., {B1 , B2 , . . . Bn } {A1 , A2 , . . . An } = . completely non-trivial if none of the B s are among the As, i.e., {B1 , B2 , . . . Bn } {A1 , A2 , . . . An } = .

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Triviality of FDs
An FD A1 A2 . . . An B1 B2 . . . Bm is trivial if the B s are a subset of the As, i.e., {B1 , B2 , . . . Bn } {A1 , A2 , . . . An }. non-trivial if at least one B is not among the As, i.e., {B1 , B2 , . . . Bn } {A1 , A2 , . . . An } = . completely non-trivial if none of the B s are among the As, i.e., {B1 , B2 , . . . Bn } {A1 , A2 , . . . An } = . What good are trivial and non-trivial dependencies?
Trivial dependencies are always true. They help simplify reasoning about FDs.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Triviality of FDs
An FD A1 A2 . . . An B1 B2 . . . Bm is trivial if the B s are a subset of the As, i.e., {B1 , B2 , . . . Bn } {A1 , A2 , . . . An }. non-trivial if at least one B is not among the As, i.e., {B1 , B2 , . . . Bn } {A1 , A2 , . . . An } = . completely non-trivial if none of the B s are among the As, i.e., {B1 , B2 , . . . Bn } {A1 , A2 , . . . An } = . What good are trivial and non-trivial dependencies?
Trivial dependencies are always true. They help simplify reasoning about FDs.

Trivial dependency rule: The FD A1 A2 . . . An B1 B2 . . . Bm is equivalent to the FD A1 A2 . . . An C1 C2 . . . Ck , where the C s are those B s that are not As, i.e., {C1 , C2 , . . . , Ck } = {B1 , B2 , . . . , Bm } {A1 , A2 , . . . , An }.
T. M. Murali October 18, 25, 2010 CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Closures of Attributes: Example


Suppose a relation with attributes A, B , C , D , E , and F satises the FDs AB C BC AD D E , CF B Given these FDs, what is the set X of attributes such that AB X is true?

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Closures of Attributes: Example


Suppose a relation with attributes A, B , C , D , E , and F satises the FDs AB C BC AD D E , CF B Given these FDs, what is the set X of attributes such that AB X is true? X = {A, B , C , D , E }, i.e., AB ABCDE .

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Closures of Attributes: Example


Suppose a relation with attributes A, B , C , D , E , and F satises the FDs AB C BC AD D E , CF B Given these FDs, what is the set X of attributes such that AB X is true? X = {A, B , C , D , E }, i.e., AB ABCDE . what is the set Y of attributes such that BCF Y is true?

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Closures of Attributes: Example


Suppose a relation with attributes A, B , C , D , E , and F satises the FDs AB C BC AD D E , CF B Given these FDs, what is the set X of attributes such that AB X is true? X = {A, B , C , D , E }, i.e., AB ABCDE . what is the set Y of attributes such that BCF Y is true? Y = {A, B , C , D , E , F }, i.e., BCF ABCDEF

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Closures of Attributes: Example


Suppose a relation with attributes A, B , C , D , E , and F satises the FDs AB C BC AD D E , CF B Given these FDs, what is the set X of attributes such that AB X is true? X = {A, B , C , D , E }, i.e., AB ABCDE . what is the set Y of attributes such that BCF Y is true? Y = {A, B , C , D , E , F }, i.e., BCF ABCDEF what is the set Z of attributes such that AF Z is true?

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Closures of Attributes: Example


Suppose a relation with attributes A, B , C , D , E , and F satises the FDs AB C BC AD D E , CF B Given these FDs, what is the set X of attributes such that AB X is true? X = {A, B , C , D , E }, i.e., AB ABCDE . what is the set Y of attributes such that BCF Y is true? Y = {A, B , C , D , E , F }, i.e., BCF ABCDEF what is the set Z of attributes such that AF Z is true? Z = {A, F }, i.e., AF AF .

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Closures of Attributes: Example


Suppose a relation with attributes A, B , C , D , E , and F satises the FDs AB C BC AD D E , CF B Given these FDs, what is the set X of attributes such that AB X is true? X = {A, B , C , D , E }, i.e., AB ABCDE . what is the set Y of attributes such that BCF Y is true? Y = {A, B , C , D , E , F }, i.e., BCF ABCDEF what is the set Z of attributes such that AF Z is true? Z = {A, F }, i.e., AF AF . X , Y , and Z are the closures of {A, B }, {B , C , F }, and {A, F }, respectively.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Closures of Attributes: Example


Suppose a relation with attributes A, B , C , D , E , and F satises the FDs AB C BC AD D E , CF B Given these FDs, what is the set X of attributes such that AB X is true? X = {A, B , C , D , E }, i.e., AB ABCDE . what is the set Y of attributes such that BCF Y is true? Y = {A, B , C , D , E , F }, i.e., BCF ABCDEF what is the set Z of attributes such that AF Z is true? Z = {A, F }, i.e., AF AF . X , Y , and Z are the closures of {A, B }, {B , C , F }, and {A, F }, respectively. {B , C , F } is a

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Closures of Attributes: Example


Suppose a relation with attributes A, B , C , D , E , and F satises the FDs AB C BC AD D E , CF B Given these FDs, what is the set X of attributes such that AB X is true? X = {A, B , C , D , E }, i.e., AB ABCDE . what is the set Y of attributes such that BCF Y is true? Y = {A, B , C , D , E , F }, i.e., BCF ABCDEF what is the set Z of attributes such that AF Z is true? Z = {A, F }, i.e., AF AF . X , Y , and Z are the closures of {A, B }, {B , C , F }, and {A, F }, respectively. {B , C , F } is a superkey.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Closures of Attributes: Denition

Given a set of attributes {A1 , A2 , . . . , An } and a set of FDs S , the closure of {A1 , A2 , . . . , An } under the FDs in S is the set of attributes {B1 , B2 , . . . , Bm } such that for 1 i m, the FD A1 A2 . . . An Bi follows from S . the closure is denoted by {A1 , A2 , . . . , An }+ .

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Closures of Attributes: Denition

Given a set of attributes {A1 , A2 , . . . , An } and a set of FDs S , the closure of {A1 , A2 , . . . , An } under the FDs in S is the set of attributes {B1 , B2 , . . . , Bm } such that for 1 i m, the FD A1 A2 . . . An Bi follows from S . the closure is denoted by {A1 , A2 , . . . , An }+ . Which attributes must {A1 , A2 , . . . , An }+ contain at a minimum?

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Closures of Attributes: Denition

Given a set of attributes {A1 , A2 , . . . , An } and a set of FDs S , the closure of {A1 , A2 , . . . , An } under the FDs in S is the set of attributes {B1 , B2 , . . . , Bm } such that for 1 i m, the FD A1 A2 . . . An Bi follows from S . the closure is denoted by {A1 , A2 , . . . , An }+ . Which attributes must {A1 , A2 , . . . , An }+ contain at a minimum? {A1 , A2 , . . . , An }. Why?

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Closures of Attributes: Denition

Given a set of attributes {A1 , A2 , . . . , An } and a set of FDs S , the closure of {A1 , A2 , . . . , An } under the FDs in S is the set of attributes {B1 , B2 , . . . , Bm } such that for 1 i m, the FD A1 A2 . . . An Bi follows from S . the closure is denoted by {A1 , A2 , . . . , An }+ . Which attributes must {A1 , A2 , . . . , An }+ contain at a minimum? {A1 , A2 , . . . , An }. Why? A1 A2 . . . An Ai is a trivial FD.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Closures of Attributes: Algorithm


Given a set of attributes {A1 , A2 , . . . , An } and a set of FDs S , compute X = {A1 , A2 , . . . , An }+ .

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Closures of Attributes: Algorithm


Given a set of attributes {A1 , A2 , . . . , An } and a set of FDs S , compute X = {A1 , A2 , . . . , An }+ . 1. Use the splitting rule so that each FD in S has one attribute on the right. 2. Set X {A1 , A2 , . . . , An }. 3. Find an FD B1 B2 . . . Bk C in S such that {B1 , B2 , . . . Bk } X but C X. 4. Add C to X . 5. Repeat the last two steps until you cannot nd such an attribute C . 6. The nal value of X is the desired closure.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Closures of Attributes: Algorithm


Given a set of attributes {A1 , A2 , . . . , An } and a set of FDs S , compute X = {A1 , A2 , . . . , An }+ . 1. Use the splitting rule so that each FD in S has one attribute on the right. 2. Set X {A1 , A2 , . . . , An }. 3. Find an FD B1 B2 . . . Bk C in S such that {B1 , B2 , . . . Bk } X but C X. 4. Add C to X . 5. Repeat the last two steps until you cannot nd such an attribute C . 6. The nal value of X is the desired closure. Why does the algorithm compute the closure correctly? Read Chapter 3.2.5 of the textbook.
T. M. Murali October 18, 25, 2010 CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Why is the Concept of Closures Useful?


1. Prove correctness of rules for manipulating FDs.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Why is the Concept of Closures Useful?


1. Prove correctness of rules for manipulating FDs. For example,
Transitive rule: if A1 A2 . . . An B1 B2 . . . Bm and B1 B2 . . . Bm C1 C2 . . . Ck then A1 A2 . . . An C1 C2 . . . Ck .

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Why is the Concept of Closures Useful?


1. Prove correctness of rules for manipulating FDs. For example,
Transitive rule: if A1 A2 . . . An B1 B2 . . . Bm and B1 B2 . . . Bm C1 C2 . . . Ck then A1 A2 . . . An C1 C2 . . . Ck . To prove this rule, simply check if + {C1 , C2 , . . . , Ck } {A1 , A2 , . . . , An } .

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Why is the Concept of Closures Useful?


1. Prove correctness of rules for manipulating FDs. For example,
Transitive rule: if A1 A2 . . . An B1 B2 . . . Bm and B1 B2 . . . Bm C1 C2 . . . Ck then A1 A2 . . . An C1 C2 . . . Ck . To prove this rule, simply check if + {C1 , C2 , . . . , Ck } {A1 , A2 , . . . , An } .

2. Check if a new FD A1 A2 . . . An B follows from a set of FDs S : simply check if B is in {A1 , A2 , . . . An }+ under S .

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Why is the Concept of Closures Useful?


1. Prove correctness of rules for manipulating FDs. For example,
Transitive rule: if A1 A2 . . . An B1 B2 . . . Bm and B1 B2 . . . Bm C1 C2 . . . Ck then A1 A2 . . . An C1 C2 . . . Ck . To prove this rule, simply check if + {C1 , C2 , . . . , Ck } {A1 , A2 , . . . , An } .

2. Check if a new FD A1 A2 . . . An B follows from a set of FDs S : simply check if B is in {A1 , A2 , . . . An }+ under S . 3. Procedurally dene keys.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Why is the Concept of Closures Useful?


1. Prove correctness of rules for manipulating FDs. For example,
Transitive rule: if A1 A2 . . . An B1 B2 . . . Bm and B1 B2 . . . Bm C1 C2 . . . Ck then A1 A2 . . . An C1 C2 . . . Ck . To prove this rule, simply check if + {C1 , C2 , . . . , Ck } {A1 , A2 , . . . , An } .

2. Check if a new FD A1 A2 . . . An B follows from a set of FDs S : simply check if B is in {A1 , A2 , . . . An }+ under S . 3. Procedurally dene keys. A set of attributes X is a key for a relation R if and only if
{X } is the set of all attributes of R and + for no attribute A X is {X {A}} the set of all attributes of R .
T. M. Murali October 18, 25, 2010 CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Examples of Closure Computations

Consider the bad relation Students(Id, Name, AdvisorId, AdvisorName, FavouriteAdvisorId). What are the FDs that hold in this relation? Id Name Id FavouriteAdvisorId AdvisorId AdvisorName

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Examples of Closure Computations

Consider the bad relation Students(Id, Name, AdvisorId, AdvisorName, FavouriteAdvisorId). What are the FDs that hold in this relation? Id Name Id FavouriteAdvisorId AdvisorId AdvisorName To compute the key for this relation,
1. Compute the closures for all sets of attributes. 2. Find the minimal set of attributes whose closure is the set of all attributes.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Algorithm for Computing Keys


Given a relation R (A1 , A2 , . . . , An ) and the set of all FDs S that hold in R , compute all the keys of R .

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Algorithm for Computing Keys


Given a relation R (A1 , A2 , . . . , An ) and the set of all FDs S that hold in R , compute all the keys of R . 1. For every subset K {A1 , A2 , . . . , An }, compute {K }+ . 2. If {K }+ = {A1 , A2 , . . . , An } and for every attribute A, {K {A}}+ = {A1 , A2 , . . . , An }, then output K as a key.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Algorithm for Computing Keys


Given a relation R (A1 , A2 , . . . , An ) and the set of all FDs S that hold in R , compute all the keys of R . 1. For every subset K {A1 , A2 , . . . , An }, compute {K }+ . 2. If {K }+ = {A1 , A2 , . . . , An } and for every attribute A, {K {A}}+ = {A1 , A2 , . . . , An }, then output K as a key. Running time of the algorithm is exponential in the number of attributes.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Armstrongs Axioms
We can use closures of attributes to determine if any FD follows from a given set of FDs. Armstrongs axioms: complete set of inference rules from which it is possible to derive every FD that follows from a given set:

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Armstrongs Axioms
We can use closures of attributes to determine if any FD follows from a given set of FDs. Armstrongs axioms: complete set of inference rules from which it is possible to derive every FD that follows from a given set: Reexivity If {B1 , B2 , . . . , Bm } {A1 , A2 , . . . , An }, then A1 A2 . . . Am B1 B2 . . . Bm (Trivial FDs).

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Armstrongs Axioms
We can use closures of attributes to determine if any FD follows from a given set of FDs. Armstrongs axioms: complete set of inference rules from which it is possible to derive every FD that follows from a given set: Reexivity If {B1 , B2 , . . . , Bm } {A1 , A2 , . . . , An }, then A1 A2 . . . Am B1 B2 . . . Bm (Trivial FDs). Augmentation If A1 A2 . . . Am B1 B2 . . . Bm , then A1 A2 . . . Am C1 C2 . . . Ck B1 B2 . . . Bm C1 C2 . . . Ck , for any set of attributes {C1 , C2 , . . . , Ck }.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Armstrongs Axioms
We can use closures of attributes to determine if any FD follows from a given set of FDs. Armstrongs axioms: complete set of inference rules from which it is possible to derive every FD that follows from a given set: Reexivity If {B1 , B2 , . . . , Bm } {A1 , A2 , . . . , An }, then A1 A2 . . . Am B1 B2 . . . Bm (Trivial FDs). Augmentation If A1 A2 . . . Am B1 B2 . . . Bm , then A1 A2 . . . Am C1 C2 . . . Ck B1 B2 . . . Bm C1 C2 . . . Ck , for any set of attributes {C1 , C2 , . . . , Ck }. Transitivity If A1 A2 . . . An B1 B2 . . . Bm and B1 B2 . . . Bm C1 C2 . . . Ck then A1 A2 . . . An C1 C2 . . . Ck .

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Dierences in Notation

Relation schema R (A1 , A2 , A3 ): parentheses surround attributes, attributes separated by commas. Set of attributes {A1 , A2 , A3 }: curly braces surround attributes, attributes separated by commas. FD A1 A2 A3 : no parentheses or curly braces, attributes separated by spaces, arrows separates left hand side and right hand side. Set of FDs {A1 A2 A3 , A2 A1 }: curly braces surround FDs, FDs separated by commas.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Minimal Basis
A relation may have a large set of equivalent sets of FDs. If we are given a set S of FDs, then any set of FDs that is equivalent to S is called a basis of S .

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Minimal Basis
A relation may have a large set of equivalent sets of FDs. If we are given a set S of FDs, then any set of FDs that is equivalent to S is called a basis of S . We will limit ourselves to bases in which each FD has only one attribute on the right hand side.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Minimal Basis
A relation may have a large set of equivalent sets of FDs. If we are given a set S of FDs, then any set of FDs that is equivalent to S is called a basis of S . We will limit ourselves to bases in which each FD has only one attribute on the right hand side. A set B of FDs is a minimal basis for a relation R if
1. Every FD in B has one attribute on the right hand side. 2. If we remove any FD from B , then the result is not a basis. 3. If for any FD in B , we remove one or more attributes from the left hand side of the FD, then the result is not a basis.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Example of Minimal Basis

R (A, B , C ) is a relation such that each attribute functionally determines the other two attributes. What are the FDs that hold in R and what are the minimal bases? (Assume only one attribute on the right-hand side, only non-trivial FDs)

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Example of Minimal Basis

R (A, B , C ) is a relation such that each attribute functionally determines the other two attributes. What are the FDs that hold in R and what are the minimal bases? (Assume only one attribute on the right-hand side, only non-trivial FDs) FDs:

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Example of Minimal Basis

R (A, B , C ) is a relation such that each attribute functionally determines the other two attributes. What are the FDs that hold in R and what are the minimal bases? (Assume only one attribute on the right-hand side, only non-trivial FDs) FDs: A B , A C , B A, B C , C A, C B ,

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Example of Minimal Basis

R (A, B , C ) is a relation such that each attribute functionally determines the other two attributes. What are the FDs that hold in R and what are the minimal bases? (Assume only one attribute on the right-hand side, only non-trivial FDs) FDs: A B , A C , B A, B C , C A, C B , AB C , BC A, AC B .

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Example of Minimal Basis

R (A, B , C ) is a relation such that each attribute functionally determines the other two attributes. What are the FDs that hold in R and what are the minimal bases? (Assume only one attribute on the right-hand side, only non-trivial FDs) FDs: A B , A C , B A, B C , C A, C B , AB C , BC A, AC B . Minimal bases:

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

Basics of FDs

Manipulating FDs

Closures and Keys

Minimal Bases

Example of Minimal Basis

R (A, B , C ) is a relation such that each attribute functionally determines the other two attributes. What are the FDs that hold in R and what are the minimal bases? (Assume only one attribute on the right-hand side, only non-trivial FDs) FDs: A B , A C , B A, B C , C A, C B , AB C , BC A, AC B . Minimal bases: {A B , B A, B C , C B }, {A B , B C , C A}, and others.

T. M. Murali

October 18, 25, 2010

CS 4604: Functional Dependencies

S-ar putea să vă placă și