FUNCTIONAL DEPENDENCY
PRINCIPLES OF DATA AND KNOWLEDGE
BASE SYSTEMS
NAME: ALAA NOOR
MATRIKL NR.: 805642
What is Functional Dependency (FDs)?
Functional dependency is a relationship that exists when one attribute uniquely determines
another attribute.
FDs are a generalization of keys.
It is the central part of relational database design theory.
A functional dependency is denoted by an arrow "→". Such as the functional dependency of A on
B is represented by A →B
EXAMPLE OF FD:
Student_ID Name Age City
01 Alaa 21 Potsdam
02 Iftekhar 25 Potsdam
03 Aziha 22 Berlin
• Here if we know the value of
Student_ID, we can obtain the Name,
Age and City of that student. By this,
we can say that the City, Name, and
Age are functionally dependent on
Student_ID.
• Functional dependency can be written
as: Student_ID → Name, Age, City.
Table 1. Student table
Key Terms:
Key Terms Description
Axiom Axioms is a set of inference rules used to infer all
the functional dependencies on a relational
database.
Decomposition It is a rule that suggests if you have a table that
appears to contain two entities which are
determined by the same primary key(PK) then
you should consider breaking them up into two
different tables.
Dependent It is displayed on the right side of the functional
dependency.
Determinant It is displayed on the left side of the functional
dependency.
Union It suggests that if two tables are separate, and
the PK is the same, you should consider putting
them together.
Table 2. Key terms of Functional Dependency
Rules of Functional Dependency:
1. Reflexive rule : If B is a subset of A, then A→B holds by reflexivity rule.
2. Augmentation rule : It is also known as a partial dependency, it says if A->B
holds, then AC->BC for any attribute C also holds.
3. Transitivity rule : This rule is very much similar to the transitive rule in
algebra if A->B holds and B->C holds, then A->C also holds.
Types of Functional Dependency:
 Transitive Dependency
 Trivial functional dependency
 Non-trivial functional dependency
Figure 1. Types of FDs
Transitive Dependency:
A functional dependency is said to be transitive if it is indirectly formed by
two functional dependencies.
X -> Z is a transitive dependency if the following three functional
dependencies hold true:
• X->Y
• Y does not ->X
• Y->Z
A transitive dependency can only occur in a relation of three or more
attributes. This dependency helps us normalizing the database in 3NF (3rd
Normal Form).
Transitive Dependency Example:
Book Author Author Age
Game of Thrones George R. R. Martin 66
Harry Potter J.K. Rowling 49
Dying of the Light George R. R. Martin 66
• {Book} ->{Author} (if we know the book, we can know the author name)
• {Author} does not -> {Book}
• {Author} -> {Author_age}
Therefore according to the rule of transitive dependency:
• {Book} -> {Author_age} should hold, that makes sense because if we know the book
name we can know the author’s age.
Table 3. Book table
Trivial Functional Dependency:
The dependency of an attribute on a set of attributes is known as trivial
functional dependency if the set of attributes includes that attribute.
Symbolically:
• A ->B is trivial functional dependency if B is a subset of A.
• The following dependencies are also trivial: A->A & B->B
Trivial FD Example:
• {Company_Id, Company_Name} -> {Company_Id} is a trivial functional
dependency as Company_Id is a subset of {Company_Id, Company_Name}.
• Also, Company_Id -> Company_Id & Company_Name -> Company_Name are
trivial dependencies too.
Company_Id Company_Name
C2 Apple
C3 Facebook
C4 Google
Table 4. Company Table
Non-Trivial Functional Dependency
A nontrivial functional dependency occurs when A->B holds true where B is
not a subset of A.
For example:
Company_Id-> Company_Name
The above is non-trivial functional dependency since Company_Name is
not a subset of Company_Id.
Contd..
Any FD such as A1, . . . , An → B1, . . . , Bm will cause redundant storage unless A1,
. . . , An is a key, so that each combination of attribute values for A1, . . . , An can
occur only once.
Avoid (proper) FDs by transforming them into key constraints. This is what
normalization does.
Therefore BCNF is used here.
Boyce-Codd Normal Form (BCNF)
A relational schema R is considered to be in Boyce–Codd normal form (BCNF) if,
for every one of its dependencies A → B, one of the following conditions holds
true:
• A → B is a trivial functional dependency
• A relation R is in BCNF if and only if: whenever there is a nontrivial FD
A1, . . . , An → B1, . . . , Bm for R, it is the case that {A1, A2, ... , An} is a superkey
for R.
#That is, the left side of every nontrivial FD must be a superkey.
Example (Not in BCNF):
The nontrivial functional dependencies in the table are:
• author → nationality
• book title → genre, number of pages
We can easily see that the only KEY is the set {author, book title}
Author Nationality Book Title Genre Number of pages
William
Shakespeare
English The Tempest Comedy 215
Emily Brontë Irish Wuthering Heights Gothic 540
Jeffrey Ullman American Database Systems Textbook 500
Jennifer Widom American Database Systems Textbook 500
Table 5. Author table
Example (in BCNF):
Author Nationality
William Shakespeare English
Emily Brontë Irish
Jeffrey Ullman American
Jennifer Widom American
Author Book Title
William Shakespeare The Tempest
Emily Brontë Wuthering Heights
Jeffrey Ullman Database Systems
Jennifer Widom Database Systems
Table 6. Author1 table Table 7. Author2 table
Contd..
The functional dependencies for this schema are the same as before:
• author → nationality
• book title → genre, number of pages
The key of the first table is {author}. The key of the second table is {author, book title}. The key of the
third table is {book title}. There are no functional dependencies violating the BCNF rules, so the
schema is in Boyce-Codd Normal Form.
Book Title Genre Number of Pages
The Tempest Comedy 215
Wuthering Heights Gothic 540
Database Systems Textbook 500
Table 8. Author3 table
Advantages of Functional Dependency:
• Functional Dependency removes data redundancy where the same values
should not be repeated at multiple locations in the same database table.
• It maintains the quality of data in the database.
• FD allows clearly defined meanings and constraints of databases.
• It helps in identifying bad designs of the database.
• It expresses the facts about the database design.
References
H. Garcia-Molina, J. Ullman, and J.Widom. Database Systems: The Complete
Book. Prentice Hall Press, second edition, 2008. [Ch. 3]
https://www.guru99.com/dbms-functional-dependency.html
https://www.geeksforgeeks.org/types-of-functional-dependencies-in-dbms
https://www.tutorialspoint.com/Functional-dependency-in-DBMS
https://www.tutorialandexample.com/functional-dependencies/
Functional Dependency

Functional Dependency

  • 1.
    FUNCTIONAL DEPENDENCY PRINCIPLES OFDATA AND KNOWLEDGE BASE SYSTEMS NAME: ALAA NOOR MATRIKL NR.: 805642
  • 2.
    What is FunctionalDependency (FDs)? Functional dependency is a relationship that exists when one attribute uniquely determines another attribute. FDs are a generalization of keys. It is the central part of relational database design theory. A functional dependency is denoted by an arrow "→". Such as the functional dependency of A on B is represented by A →B
  • 3.
    EXAMPLE OF FD: Student_IDName Age City 01 Alaa 21 Potsdam 02 Iftekhar 25 Potsdam 03 Aziha 22 Berlin • Here if we know the value of Student_ID, we can obtain the Name, Age and City of that student. By this, we can say that the City, Name, and Age are functionally dependent on Student_ID. • Functional dependency can be written as: Student_ID → Name, Age, City. Table 1. Student table
  • 4.
    Key Terms: Key TermsDescription Axiom Axioms is a set of inference rules used to infer all the functional dependencies on a relational database. Decomposition It is a rule that suggests if you have a table that appears to contain two entities which are determined by the same primary key(PK) then you should consider breaking them up into two different tables. Dependent It is displayed on the right side of the functional dependency. Determinant It is displayed on the left side of the functional dependency. Union It suggests that if two tables are separate, and the PK is the same, you should consider putting them together. Table 2. Key terms of Functional Dependency
  • 5.
    Rules of FunctionalDependency: 1. Reflexive rule : If B is a subset of A, then A→B holds by reflexivity rule. 2. Augmentation rule : It is also known as a partial dependency, it says if A->B holds, then AC->BC for any attribute C also holds. 3. Transitivity rule : This rule is very much similar to the transitive rule in algebra if A->B holds and B->C holds, then A->C also holds.
  • 6.
    Types of FunctionalDependency:  Transitive Dependency  Trivial functional dependency  Non-trivial functional dependency Figure 1. Types of FDs
  • 7.
    Transitive Dependency: A functionaldependency is said to be transitive if it is indirectly formed by two functional dependencies. X -> Z is a transitive dependency if the following three functional dependencies hold true: • X->Y • Y does not ->X • Y->Z A transitive dependency can only occur in a relation of three or more attributes. This dependency helps us normalizing the database in 3NF (3rd Normal Form).
  • 8.
    Transitive Dependency Example: BookAuthor Author Age Game of Thrones George R. R. Martin 66 Harry Potter J.K. Rowling 49 Dying of the Light George R. R. Martin 66 • {Book} ->{Author} (if we know the book, we can know the author name) • {Author} does not -> {Book} • {Author} -> {Author_age} Therefore according to the rule of transitive dependency: • {Book} -> {Author_age} should hold, that makes sense because if we know the book name we can know the author’s age. Table 3. Book table
  • 9.
    Trivial Functional Dependency: Thedependency of an attribute on a set of attributes is known as trivial functional dependency if the set of attributes includes that attribute. Symbolically: • A ->B is trivial functional dependency if B is a subset of A. • The following dependencies are also trivial: A->A & B->B
  • 10.
    Trivial FD Example: •{Company_Id, Company_Name} -> {Company_Id} is a trivial functional dependency as Company_Id is a subset of {Company_Id, Company_Name}. • Also, Company_Id -> Company_Id & Company_Name -> Company_Name are trivial dependencies too. Company_Id Company_Name C2 Apple C3 Facebook C4 Google Table 4. Company Table
  • 11.
    Non-Trivial Functional Dependency Anontrivial functional dependency occurs when A->B holds true where B is not a subset of A. For example: Company_Id-> Company_Name The above is non-trivial functional dependency since Company_Name is not a subset of Company_Id.
  • 12.
    Contd.. Any FD suchas A1, . . . , An → B1, . . . , Bm will cause redundant storage unless A1, . . . , An is a key, so that each combination of attribute values for A1, . . . , An can occur only once. Avoid (proper) FDs by transforming them into key constraints. This is what normalization does. Therefore BCNF is used here.
  • 13.
    Boyce-Codd Normal Form(BCNF) A relational schema R is considered to be in Boyce–Codd normal form (BCNF) if, for every one of its dependencies A → B, one of the following conditions holds true: • A → B is a trivial functional dependency • A relation R is in BCNF if and only if: whenever there is a nontrivial FD A1, . . . , An → B1, . . . , Bm for R, it is the case that {A1, A2, ... , An} is a superkey for R. #That is, the left side of every nontrivial FD must be a superkey.
  • 14.
    Example (Not inBCNF): The nontrivial functional dependencies in the table are: • author → nationality • book title → genre, number of pages We can easily see that the only KEY is the set {author, book title} Author Nationality Book Title Genre Number of pages William Shakespeare English The Tempest Comedy 215 Emily Brontë Irish Wuthering Heights Gothic 540 Jeffrey Ullman American Database Systems Textbook 500 Jennifer Widom American Database Systems Textbook 500 Table 5. Author table
  • 15.
    Example (in BCNF): AuthorNationality William Shakespeare English Emily Brontë Irish Jeffrey Ullman American Jennifer Widom American Author Book Title William Shakespeare The Tempest Emily Brontë Wuthering Heights Jeffrey Ullman Database Systems Jennifer Widom Database Systems Table 6. Author1 table Table 7. Author2 table
  • 16.
    Contd.. The functional dependenciesfor this schema are the same as before: • author → nationality • book title → genre, number of pages The key of the first table is {author}. The key of the second table is {author, book title}. The key of the third table is {book title}. There are no functional dependencies violating the BCNF rules, so the schema is in Boyce-Codd Normal Form. Book Title Genre Number of Pages The Tempest Comedy 215 Wuthering Heights Gothic 540 Database Systems Textbook 500 Table 8. Author3 table
  • 17.
    Advantages of FunctionalDependency: • Functional Dependency removes data redundancy where the same values should not be repeated at multiple locations in the same database table. • It maintains the quality of data in the database. • FD allows clearly defined meanings and constraints of databases. • It helps in identifying bad designs of the database. • It expresses the facts about the database design.
  • 18.
    References H. Garcia-Molina, J.Ullman, and J.Widom. Database Systems: The Complete Book. Prentice Hall Press, second edition, 2008. [Ch. 3] https://www.guru99.com/dbms-functional-dependency.html https://www.geeksforgeeks.org/types-of-functional-dependencies-in-dbms https://www.tutorialspoint.com/Functional-dependency-in-DBMS https://www.tutorialandexample.com/functional-dependencies/