0% found this document useful (0 votes)
4 views

Types of Functional dependencies in DBMS.

Uploaded by

shaikhtamim8209
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Types of Functional dependencies in DBMS.

Uploaded by

shaikhtamim8209
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Functional Dependency

A functional dependency A->B in a relation holds if two tuples having same value of

attribute A also have same value for attribute B. For Example, in relation STUDENT

shown in table 1, Functional Dependencies

STUD_NO->STUD_NAME, STUD_NO->STUD_PHONE hold

but

STUD_NAME->STUD_ADDR do not hold

How to find functional dependencies for a relation?

Functional Dependencies in a relation are dependent on the domain of the relation.

Consider the STUDENT relation given in Table 1.

 We know that STUD_NO is unique for each student. So STUD_NO->STUD_NAME,

STUD_NO->STUD_PHONE, STUD_NO->STUD_STATE, STUD_NO-

>STUD_COUNTRY and STUD_NO -> STUD_AGE all will be true.

 Similarly, STUD_STATE->STUD_COUNTRY will be true as if two records have

same STUD_STATE, they will have same STUD_COUNTRY as well.


 For relation STUDENT_COURSE, COURSE_NO->COURSE_NAME will be true as

two records with same COURSE_NO will have same COURSE_NAME.

Functional Dependency Set: Functional Dependency set or FD set of a relation is the

set of all FDs present in the relation. For Example, FD set for relation STUDENT shown

in table 1 is:

{ STUD_NO->STUD_NAME, STUD_NO->STUD_PHONE, STUD_NO-

>STUD_STATE, STUD_NO->STUD_COUNTRY,

STUD_NO -> STUD_AGE, STUD_STATE->STUD_COUNTRY }

Attribute Closure: Attribute closure of an attribute set can be defined as set of attributes

which can be functionally determined from it.

How to find attribute closure of an attribute set?

To find attribute closure of an attribute set:

 Add elements of attribute set to the result set.

 Recursively add elements to the result set which can be functionally determined from

the elements of the result set.

Using FD set of table 1, attribute closure can be determined as:

(STUD_NO)+ = {STUD_NO, STUD_NAME, STUD_PHONE, STUD_STATE,

STUD_COUNTRY, STUD_AGE}

(STUD_STATE) + = {STUD_STATE, STUD_COUNTRY}


How to find Candidate Keys and Super Keys using Attribute Closure?

 If attribute closure of an attribute set contains all attributes of relation, the attribute set

will be super key of the relation.

 If no subset of this attribute set can functionally determine all attributes of the

relation, the set will be candidate key as well. For Example, using FD set of table 1,

(STUD_NO, STUD_NAME) + = {STUD_NO, STUD_NAME, STUD_PHONE,

STUD_STATE, STUD_COUNTRY, STUD_AGE}

(STUD_NO)+ = {STUD_NO, STUD_NAME, STUD_PHONE, STUD_STATE,

STUD_COUNTRY, STUD_AGE}

(STUD_NO, STUD_NAME) will be super key but not candidate key because its subset

(STUD_NO)+ is equal to all attributes of the relation. So, STUD_NO will be a candidate

key.

Question: Consider the relation scheme R = {E, F, G, H, I, J, K, L, M, M} and the

set of functional dependencies {{E, F} -> {G}, {F} -> {I, J}, {E, H} -> {K, L}, K ->

{M}, L -> {N} on R. What is the key for R? (GATE-CS-2014)

A. {E, F}

B. {E, F, H}

C. {E, F, H, K, L}

D. {E}
Answer: Finding attribute closure of all given options, we get:

{E,F}+ = {EFGIJ}

{E,F,H}+ = {EFHGIJKLMN}

{E,F,H,K,L}+ = {{EFHGIJKLMN}

{E}+ = {E}

{EFH}+ and {EFHKL}+ results in set of all attributes, but EFH is minimal. So it will be

candidate key. So correct option is (B).

How to check whether an FD can be derived from a given FD set?

To check whether an FD A->B can be derived from an FD set F,

1. Find (A)+ using FD set F.

2. If B is subset of (A) +, then A->B is true else not true.

Question: In a schema with attributes A, B, C, D and E following set of functional

dependencies are given

{A -> B, A -> C, CD -> E, B -> D, E -> A}

Which of the following functional dependencies is NOT implied by the above set?

(GATE IT 2005)

A. CD -> AC

B. BD -> CD

C. BC -> CD

D. AC -> BC
Answer: Using FD set given in question,

(CD)+ = {CDEAB} which means CD -> AC also holds true.

(BD)+ = {BD} which means BD -> CD can’t hold true. So this FD is no implied in FD

set. So (B) is the required option.

Others can be checked in the same way.

Prime and non-prime attributes

Attributes which are parts of any candidate key of relation are called as prime attribute,

others are non-prime attributes. For Example, STUD_NO in STUDENT relation is prime

attribute, others are non-prime attribute.

Question: Consider a relation scheme R = (A, B, C, D, E, H) on which the following

functional dependencies hold: {A–>B, BC–> D, E–>C, D–>A}. What are the

candidate keys of R? [GATE 2005]

(a) AE, BE

(b) AE, BE, DE

(c) AEH, BEH, BCH

(d) AEH, BEH, DEH

Answer: (AE) + = {ABECD} which is not set of all attributes. So AE is not a candidate

key. Hence option A and B are wrong.

(AEH)+ = {ABCDEH}

(BEH)+ = {BEHCDA}

(BCH)+ = {BCHDA} which is not set of all attributes. So BCH is not a candidate key.
Hence option C is wrong.

So correct answer is D.

Types of Functional dependencies in DBMS


Prerequisite: Functional dependency and attribute closure
A functional dependency is a constraint that specifies the relationship between two sets of
attributes where one set can accurately determine the value of other sets. It is denoted as X
→ Y, where X is a set of attributes that is capable of determining the value of Y. The
attribute set on the left side of the arrow, X is called Determinant, while on the right
side, Y is called the Dependent. Functional dependencies are used to mathematically
express relations among database entities and are very important to understand advanced
concepts in Relational Database System and understanding problems in competitive exams
like Gate.
Example:

roll_no name dept_name dept_building

42 abc CO A4

43 pqr IT A3the

44 xyz CO A4

45 xyz IT A3

46 mno EC B2

47 jkl ME B2

From the above table we can conclude some valid functional dependencies:
 roll_no → { name, dept_name, dept_building },→ Here, roll_no can determine values
of fields name, dept_name and dept_building, hence a valid Functional dependency
 roll_no → dept_name , Since, roll_no can determine whole set of {name, dept_name,
dept_building}, it can determine its subset dept_name also.
 dept_name → dept_building , Dept_name can identify the dept_building accurately,
since departments with different dept_name will also have a different dept_building
 More valid functional dependencies: roll_no → name, {roll_no, name} ⇢ {dept_name,
dept_building}, etc.
Here are some invalid functional dependencies:
 name → dept_name Students with the same name can have different dept_name, hence
this is not a valid functional dependency.
 dept_building → dept_name There can be multiple departments in the same building,
For example, in the above table departments ME and EC are in the same building B2,
hence dept_building → dept_name is an invalid functional dependency.
 More invalid functional dependencies: name → roll_no, {name, dept_name} →
roll_no, dept_building → roll_no, etc.
Armstrong’s axioms/properties of functional dependencies:
1. Reflexivity: If Y is a subset of X, then X→Y holds by reflexivity rule
For example, {roll_no, name} → name is valid.
2. Augmentation: If X → Y is a valid dependency, then XZ → YZ is also valid by the
augmentation rule.
For example, If {roll_no, name} → dept_building is valid, hence {roll_no, name,
dept_name} → {dept_building, dept_name} is also valid.→
3. Transitivity: If X → Y and Y → Z are both valid dependencies, then X→Z is also
valid by the Transitivity rule.
For example, roll_no → dept_name & dept_name → dept_building, then roll_no →
dept_building is also valid.
Types of Functional dependencies in DBMS:
1. Trivial functional dependency
2. Non-Trivial functional dependency
3. Multivalued functional dependency
4. Transitive functional dependency

1. Trivial Functional Dependency


In Trivial Functional Dependency, a dependent is always a subset of the determinant.
i.e. If X → Y and Y is the subset of X, then it is called trivial functional dependency
For example,

roll_no name age

42 abc 17

43 pqr 18

44 xyz 18

Here, {roll_no, name} → name is a trivial functional dependency, since the


dependent name is a subset of determinant set {roll_no, name}
Similarly, roll_no → roll_no is also an example of trivial functional dependency.
2. Non-trivial Functional Dependency
In Non-trivial functional dependency, the dependent is strictly not a subset of the
determinant.
i.e. If X → Y and Y is not a subset of X, then it is called Non-trivial functional dependency.
For example,
roll_no name age

42 abc 17

43 pqr 18

44 xyz 18

Here, roll_no → name is a non-trivial functional dependency, since the


dependent name is not a subset of determinant roll_no
Similarly, {roll_no, name} → age is also a non-trivial functional dependency,
since age is not a subset of {roll_no, name}
3. Multivalued Functional Dependency
In Multivalued functional dependency, entities of the dependent set are not
dependent on each other.
i.e. If a → {b, c} and there exists no functional dependency between b and c, then it is
called a multivalued functional dependency.
For example,

roll_no name agethe

42 abc 17the

43 pqr 18

44 xyz 18

45 abc 19
Here, roll_no → {name, age} is a multivalued functional dependency, since the
dependents name & age are not dependent on each other(i.e. name → age or age →
name doesn’t exist !)
4. Transitive Functional Dependency
In transitive functional dependency, dependent is indirectly dependent on determinant.
i.e. If a → b & b → c, then according to axiom of transitivity, a → c. This is a transitive
functional dependency
For example,

enrol_no name dept building_no

42 abc CO 4

43 pqr EC 2

44 xyz IT 1

45 abc EC 2

Here, enrol_no → dept and dept → building_no,


Hence, according to the axiom of transitivity, enrol_no → building_no is a valid
functional dependency. This is an indirect functional dependency, hence called Transitive
functional dependency.

You might also like