0% found this document useful (0 votes)
16 views7 pages

DBMS - U3 Functional Dependencies

Uploaded by

harshitkamra2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views7 pages

DBMS - U3 Functional Dependencies

Uploaded by

harshitkamra2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

DBMS (KCS501)

DBMS: Functional Dependencies


 The functional dependency is a relationship that exists between two attributes. It typically exists between the
primary key and non-key attribute within a table.
 Introduced by E. F. Codd, it helps in preventing data redundancy and gets to know about bad designs.
 To understand the concept thoroughly, let us consider P is a relation with attributes A and B. Functional
Dependency is represented by -> (arrow sign)
 Then the following will represent the functional dependency between attributes with an arrow sign −
A -> B

Assume we have an employee table with attributes: Emp_Id, Emp_Name, Emp_Address.


Here Emp_Id attribute can uniquely identify the Emp_Name attribute of employee table because if we know
the Emp_Id, we can tell that employee name associated with it.
Functional dependency can be written as:
Emp_Id → Emp_Name
We can say that Emp_Name is functionally dependent on Emp_Id.

Types of Functional dependency

Department of Computer Science & Engineering, BBDEC by: Alok Kr Gupta


DBMS (KCS501)
1. Trivial functional dependency
o A → B has trivial functional dependency if B is a subset of A.
o The following dependencies are also trivial like: A → A, B → B
Example:
Consider a table with two columns Employee_Id and Employee_Name.
{Employee_id, Employee_Name} → Employee_Id is a trivial functional dependency as
Employee_Id is a subset of {Employee_Id, Employee_Name}.
Also, Employee_Id → Employee_Id and Employee_Name → Employee_Name are trivial dependencies too.

2. Non-trivial functional dependency


o A → B has a non-trivial functional dependency if B is not a subset of A.
o When A intersection B is NULL, then A → B is called as complete non-trivial.
Example:
ID → Name,
Name → DOB

Armstrong's axioms (rules)/Inference Rules (IR):


 The Armstrong's axioms are the basic inference rule.
 Armstrong's axioms are used to conclude functional dependencies on a relational database.
 The inference rule is a type of assertion. It can apply to a set of FD(functional dependency) to derive other FD.
 Using the inference rule, we can derive additional functional dependency from the initial set.
The Functional dependency has mainly 2 types of inference rule:

Department of Computer Science & Engineering, BBDEC by: Alok Kr Gupta


DBMS (KCS501)
Primary Rules: (“RAT” Rules)
1. Reflexive Rule
In the reflexive rule, if Y is a subset of X, then X determines Y.
If X ⊇ Y then X → Y
2. Augmentation Rule
The augmentation is also called as a partial dependency. In augmentation, if X determines Y, then XZ
determines YZ for any Z.
If X → Y then XZ → YZ
3. Transitive Rule
In the transitive rule, if X determines Y and Y determine Z, then X must also determine Z.
If X → Y and Y → Z then X → Z

Secondary Rules:
1. Union Rule
Union rule says, if X determines Y and X determines Z, then X must also determine Y and Z.
If X → Y and X → Z then X → YZ
2. Decomposition Rule
Decomposition rule is also known as project rule. It is the reverse of union rule.
This Rule says, if X determines Y and Z, then X determines Y and X determines Z separately.
If X → YZ then X → Y and X → Z
3. Composition Rule
It is just opposite of Decomposition rule.
This Rule says, if X determines Y and Z determines W, then XZ determines YW.
If X → Y & Z → W then XZ → YW
4. Pseudo transitive Rule
In Pseudo transitive Rule, if X determines Y and YZ determines W, then XZ determines W.
If X → Y and YZ → W then XZ → W

Department of Computer Science & Engineering, BBDEC by: Alok Kr Gupta


DBMS (KCS501)
Problem:
A B C D E F
a 2 3 4 5 1
2 a 3 4 5 2
a 2 3 6 5 3
a 2 3 6 6 4
Which Fds are valid?
1. A->BC (Valid)
2. E->F (Invalid)
3. DE->C (Valid)
4. C->DE (Invalid)
5. BC->A (Valid)
6. CD->E (Invalid)
7. BCD->E (Invalid)

Advantages of FDs:
 Functional Dependency avoids data redundancy. Therefore same data do not repeat at multiple locations in

that database
 It helps you to maintain the quality of data in the database

 It helps you to defined meanings and constraints of databases

 It helps you to identify bad designs

 It helps you to find the facts regarding the database design

Equivalence of Two Sets of Functional Dependencies-


 Two different sets of functional dependencies for a given relation may or may not be equivalent.
 If F and G are the two sets of functional dependencies, then following 3 cases are possible-
Case-01: F covers G (F ⊇ G)
Case-02: G covers F (G ⊇ F)
Case-03: Both F and G cover each other (F = G)

Department of Computer Science & Engineering, BBDEC by: Alok Kr Gupta


DBMS (KCS501)
Case-01: Determining Whether F Covers G-
Following steps are followed to determine whether F covers G or not-
Step-01:
 Take the functional dependencies of set G into consideration.
 For each functional dependency X → Y, find the closure of X using the functional dependencies of set G.
Step-02:
 Take the functional dependencies of set G into consideration.
 For each functional dependency X → Y, find the closure of X using the functional dependencies of set F.
Step-03:
 Compare the results of Step-01 and Step-02.
 If the functional dependencies of set F has determined all those attributes that were determined by the
functional dependencies of set G, then it means F covers G.
 Thus, we conclude F covers G (F ⊇ G) otherwise not.

Case-02: Determining Whether G Covers F-


Following steps are followed to determine whether G covers F or not-
Step-01:
 Take the functional dependencies of set F into consideration.
 For each functional dependency X → Y, find the closure of X using the functional dependencies of set F.
Step-02:
 Take the functional dependencies of set F into consideration.
 For each functional dependency X → Y, find the closure of X using the functional dependencies of set G.
Step-03:
 Compare the results of Step-01 and Step-02.
 If the functional dependencies of set G has determined all those attributes that were determined by the
functional dependencies of set F, then it means G covers F.
 Thus, we conclude G covers F (G ⊇ F) otherwise not.

Case-03: Determining Whether Both F and G Cover Each Other-


 If F covers G and G covers F, then both F and G cover each other.
 Thus, if both the above cases hold true, we conclude both F and G cover each other (F = G).

Department of Computer Science & Engineering, BBDEC by: Alok Kr Gupta


DBMS (KCS501)
Example:
A relation R (A , C , D , E , H) is having two functional dependencies sets F and G as shown-
Set F-
A→C
AC → D
E → AD
E→H
Set G-
A → CD
E → AH

Which of the following holds true?


(A) G ⊇ F
(B) F ⊇ G
(C) F = G
(D) All of the above

Solution-
Determining whether F covers G-

Step-01:
 (A)+ = { A , C , D } // closure of left side of A → CD using set G
 (E)+ = { A , C , D , E , H } // closure of left side of E → AH using set G

Step-02:
 (A)+ = { A , C , D } // closure of left side of A → CD using set F
 (E)+ = { A , C , D , E , H } // closure of left side of E → AH using set F

Step-03:

Comparing the results of Step-01 and Step-02, we find-

Department of Computer Science & Engineering, BBDEC by: Alok Kr Gupta


DBMS (KCS501)
 Functional dependencies of set F can determine all the attributes which have been determined by the functional
dependencies of set G.
 Thus, we conclude F covers G i.e. F ⊇ G.

Determining whether G covers F-


Step-01:
 (A)+ = { A , C , D } // closure of left side of A → C using set F
 (AC)+ = { A , C , D } // closure of left side of AC → D using set F
 (E)+ = { A , C , D , E , H } // closure of left side of E → AD and E → H using set F

Step-02:
 (A)+ = { A , C , D } // closure of left side of A → C using set G
 (AC)+ = { A , C , D } // closure of left side of AC → D using set G
 (E)+ = { A , C , D , E , H } // closure of left side of E → AD and E → H using set G

Step-03:
Comparing the results of Step-01 and Step-02, we find-
 Functional dependencies of set G can determine all the attributes which have been determined by the functional
dependencies of set F.
 Thus, we conclude G covers F i.e. G ⊇ F.

Determining whether both F and G cover each other-


 From Step-01, we conclude F covers G.
 From Step-02, we conclude G covers F.
 Thus, we conclude both F and G cover each other i.e. F = G.

Thus, Option (D) is correct.

Department of Computer Science & Engineering, BBDEC by: Alok Kr Gupta

You might also like