0% found this document useful (0 votes)
76 views30 pages

Dependencies in DBMS

The document discusses various types of dependencies in databases including functional dependency, partial functional dependency, fully functional dependency, transitive functional dependency, and trivial functional dependency. It provides examples and definitions for each. It also covers Armstrong's axiom rules for deriving new functional dependencies from a given set of dependencies, and how to find candidate keys and super keys using attribute closure.

Uploaded by

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

Dependencies in DBMS

The document discusses various types of dependencies in databases including functional dependency, partial functional dependency, fully functional dependency, transitive functional dependency, and trivial functional dependency. It provides examples and definitions for each. It also covers Armstrong's axiom rules for deriving new functional dependencies from a given set of dependencies, and how to find candidate keys and super keys using attribute closure.

Uploaded by

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

Dependencies in DBMS

Dependency
A dependency occurs in a database when information
stored in the same database table uniquely determines
other information stored in the same table.
Functional Dependency
A functional dependency is defined as a constraint between
two sets of attributes in a relation from a database.
Given a relation R, a set of attributes X in R is said to
functionally determine another attribute Y, also in R,
(written X → Y) if and only if each X value is associated with
at most one Y value.
An attribute is functionally dependent on another if
we can use the value of one attribute to determine
the value of another.
We use the arrow symbol → to indicate a functional
dependency. X → Y is read X functionally
determines Y
X is the determinant set and Y is the dependent
attribute. Thus, given a tuple and the values of the
attributes in X, one can determine the
corresponding value of the Y attribute.
Example
Functional Dependence (FD)
Functional Dependence (FD)
Partial functional dependency
In a relation R(A,B,C,D) if the key is (A,B) and
 (A,B)->(C,D) holds, also (A)->(C) also
holds, C is said to be partially dependent
on (A,B)
Partial Functional Dependency occurs only
in relation with composite keys. Partial
functional dependency occurs when one or
more non key attribute are depending on a part
of the primary key.
Example

Table: Stud_id, Course_id, Stud_name, Course_Name


Where: Primary Key = Stud_id + Course_id
Then: To determine name of student we use only
Stud_id, which is part of primary key.
{Stud_id} -> {Stud_Name}
Hence,Stud_name is partially dependent on
Stud_id. This is called partial dependency.
Fully functional dependency
 In R(A,B,C) if (A,B)->C holds and
neither A->C nor B->C holds then it s fully
functionally dependent on (A,B).
A functional dependency X → Y is a full functional
dependency if removal of any attribute A from X
means that the dependency does not hold any more
For example, in relation Supplier, different cities may have the same status. It
may be possible that cities like Amritsar, Jalandhar may have the same status
10.
So, the City is not FD on Status.
But, the combination of Sno, Status can give only one corresponding City
because “Sno” is unique. Thus,
                                     (Sno, Status)  City
It means city is FD on composite attribute (Sno, Status) however City is not
fully functional dependent on this composite attribute, which is explained
below:
                                     (Sno, Status)  City
                                              X               Y
 
Here Y is FD on X, but X has two proper subsets Sno and Status; city is FD on
one proper subset of X i.e. Sno
                                        Sno  City
According to FFD definition, Y must not be FD on any proper subset of X, but
here City is FD in one subset of X i.e. Sno, so City is not FFD on (Sno, Status)
Consider another case of SP table:
Here, Qty is FD on combination of Sno, Pno.
                             (Sno, Pno)          Qty
                                     X                    Y
Here, X has two proper subsets Sno and Pno
Qty is not FD on Sno, because one Sno can supply more
than one quantity.
Qty is also not FD on Pno, because one Pno may be
supplied many times by different suppliers with different
or same quantities.
So, Qty is FFD on (Sno, Pno) .
Transitive Functional Dependency
A Transitive Functional Dependency is a functional
dependency where the determinant and the
determined both consists of non-key attributes.
 X→ Y
X non-prime attribute
Y also non prime attribute
Trivial Functional Dependency
• Trivial: If an FD X → Y holds where Y subset of X, then it is
called a trivial FD. Trivial FDs always hold.

• Non-trivial: If an FD X → Y holds where Y is not subset of


X, then it is called non-trivial FD.
Armstrong’s Axiom Rules
Armstrong axioms consist of the following following
rules:
Primary rules
Reflexivity: If Y ⊆ X, then X → Y.
Augmentation: If X → Y , then XZ → YZ.
Transitivity: If X → Y and Y → Z, then X → Z.
Secondary rules
Union
    If A holds B and A holds C, then A holds BC.
    If{A → B} and {A → C}, then {A → BC}
Decomposition
    If A holds BC and A holds B, then A holds C.
    If{A → BC} and {A → B}, then {A → C}
Pseudo Transitivity
    If A holds B and BC holds D, then AC holds D.
    If{A → B} and {BC → D}, then {AC → D}
Example 1
Consider relation E = (P, Q, R, S, T, U) having set of
Functional Dependencies (FD).
P → Q             P → R
QR → S          Q → T
QR → U          PR → U
Calculate some members of Axioms as follows:
1. P → T
In the above FD set, P → Q and Q → T
So, Using Transitive Rule: If {A → B} and {B → C},
then {A → C}
∴ If P → Q and Q → T, then P → T.
P→T
2. PR → S
In the above FD set, P → Q
As, QR → S
So, Using Pseudo Transitivity Rule: If{A → B} and
{BC → D}, then {AC → D}
∴ If P → Q and QR → S, then PR → S.
PR → S
3. QR → SU
In above FD set, QR → S and QR → U
So, Using Union Rule: If{A → B} and {A → C}, then
{A → BC}
∴ If QR → S and QR → U, then QR → SU.
QR → SU
4. PR → SU
So, Using Union Rule: If{A → B} and {A → C}, then
{A → BC}
∴ If PR → S and PR → U, then PR → SU.
PR → SU
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,
Find (A)+ using FD set F.
If B is subset of (A)+, then A->B is true else not true.
Example 2
 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?
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.
(BC)+ ={B,C,D,E,A} which means BC -> CD also holds
true.
(AC)+ ={A,C,B,D,E} which means AC -> BC also holds
true.
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. 
Note: Candidate key is the minimal super key
Example 3
 Consider the relation scheme R = {E, F, G, H, I, J,
K, L, M, N} 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 candidate key for R? 
A. {E, F}
B. {E, F, H}
C. {E, F, H, K, L}
D. {E}
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).
Example 4
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?
(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.

You might also like