Functional Dependency is a relationship between one attribute to another attribute in a Database. Typically, a non-key attribute is dependent on the primary key attribute. Any changes made in the primary key attribute bring in changes to the non-key attribute as well.
A functional dependency is represented by an arrow “→”.
Ex. : X→Y – Here X is functional dependent on Y. Here, the left side (X) is called determinant and the right side (Y) is called dependent.
Types of functional dependencies:-
- Trivial Functional Dependency
- Non-Trivial Functional Dependency
- Completely Non-Trivial Functional Dependency
- Trivial Functional Dependency: Any dependency is said to be Trivial Functional dependency if the attributes of the dependent are a subset of determinant attributes.
Ex. : A→B is a trivial dependency if B is a subset of A.
Roll_no | Name |
001 | Anish |
002 | Aryan |
003 | Chirag |
Here {Roll_no, Name} → Roll_no is a trivial functional dependency as Roll_no is a subset of {Roll_no, Name}
- Non-trivial Functional Dependency: Any dependency is said to be Non-Trivial Functional dependency if the attributes of the dependent are not a subset of determinant attributes.
Ex. : A→B is a non-trivial dependency if B is not a subset of A.
Roll_no | Name | Age |
001 | Anish | 19 |
002 | Aryan | 20 |
003 | Chirag | 19 |
Here Name → Roll_no as if we know a student’s roll no. Then we can easily find his name but Roll_no is not a subset of Name so it is a non-trivial functional dependency.
- Completely Non-trivial Functional Dependency: Any dependency is said to be Completely Non-Trivial Functional dependency if the attributes of the intersection of dependent and determinant attributes are null.
Ex. : A→B is a non-trivial dependency if A intersection B is null.
Advantages of Functional Dependency :
- It avoids data duplicity therefore data do not repeat at multiple locations of the database.
- Improves the quality of data in the database.
- It helps us identify bad designs.