Functional Dependency
Functional Dependency
By:
Navjot Kaur
System Programming Domain
Functional Dependency
Functional Dependency
X → Y
The left side of FD is known as a determinant, the right side of
the production is known as a dependent.
Functional Dependency
Assume we have an employee table with attributes: Emp_Id,
Emp_Name, Emp_Address.
Eid dept
Enamedept
Functional Dependency
1. Multivalued dependency
• Multivalued dependency occurs in the situation where there
are multiple independent multivalued attributes in a single
table.
• A multivalued dependency is a complete constraint between
two sets of attributes in a relation.
• It requires that certain tuples be present in a relation.
Types of Functional Dependency
1. Multivalued dependency
1. Multivalued dependency
Step-02:
Recursively add the attributes to the result set which can be
functionally determined from the attributes already contained
in the result set.
Closure helps to find all possible candidate keys in a
relation.
Closure: Example
1. R(ABCD)
FD {A B, B C, C D}
CK = {A}
Closure: Example
1. R(ABCD)
FD {A B, B C, C D}
B+ = { BCD}
C+ = {CD} not a CK
FD {A B, B C, C D}
A → BC
BC → DE
D→F
CF → G
Closure
Closure of attribute A-
A+ = { A }
= { A , B , C } ( Using A → BC )
= { A , B , C , D , E } ( Using BC → DE )
= { A , B , C , D , E , F } ( Using D → F )
= { A , B , C , D , E , F , G } ( Using CF → G )
Thus,
A+ = { A , B , C , D , E , F , G }
Closure
Closure of attribute D-
D+ = { D }
= { D , F } ( Using D → F )
We can not determine any other attribute using attributes D and F contained in the
result set.
Thus,
D+ = { D , F }
Closure
Closure of attribute set {B, C}-
{ B , C }+= { B , C }
= { B , C , D , E } ( Using BC → DE )
= { B , C , D , E , F } ( Using D → F )
= { B , C , D , E , F , G } ( Using CF → G )
Thus,
{ B , C }+ = { B , C , D , E , F , G }
Normalization
What is it and what is need of normalization:
Process of organizing data in DB.
1.Minimize redundancy in relation
2.Divide big table into small tables
Need
To remove anomalies
Normalization
• If a database design is not perfect, it may contain anomalies.
Problems Without Normalization
If a table is not properly normalized and have data redundancy
then it will not only consume extra memory space but will also
make it difficult to handle and update the database, without
facing data loss.
For example, when we try to update one data item having its
copies scattered over several places, a few instances get
updated properly while a few others are left with old values.
Such instances leave the database in an inconsistent state.
Anomalies
2. Deletion anomalies − We tried to delete a record that is
unwanted but it leads to deletion of the data that us wanted.
Example: we wanted to delete details of student but did not
want to delete branch information. Now because branch info.
Is not stored separately so it will also be deleted.
Insertion anomaly:
For Example, If we try to delete a record from STUDENT with STUD_NO =1.
Anomalies
1. Update anomalies − If data items are scattered and are not
linked to each other properly, then it could lead to strange
situations.
For example, when we try to update one data item having its
copies scattered over several places, a few instances get
updated properly while a few others are left with old values.
Such instances leave the database in an inconsistent state.
Anomalies
2. Deletion anomalies − We tried to delete a record, but parts
of it was left undeleted because of unawareness, the data is
also saved somewhere else.
Insertion anomaly:
For Example, If we try to delete a record from STUDENT with STUD_NO =1.