B.Tech - V - KCS-501 - Unit 3 - 1
B.Tech - V - KCS-501 - Unit 3 - 1
Then the following will represent the functional dependency between attributes with an
arrow sign −
A -> B
Example
The following is an example that would make it easier to understand functional
dependency −
The DeptId is our primary key. Here, DeptId uniquely identifies the DeptName attribute.
This is because if you want to know the department name, then at first you need to have
the DeptId.
DeptId DeptName
001 Finance
002 Marketing
003 HR
Therefore, the above functional dependency between DeptId and DeptName can be
determined as DeptId is functionally dependent on DeptName −
For example:
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.
Emp_Id → Emp_Name
Example:
Example:
1. ID → Name,
2. Name → DOB
A ->B
3. Partial Dependency
Partial Dependency occurs when a non-prime attribute is functionally dependent on part
of a candidate key.
The 2nd Normal Form (2NF) eliminates the Partial Dependency.
Let us see an example −
Example
<StudentProject>
StudentID ProjectNo StudentName ProjectName
<ProjectInfo>
ProjectNo ProjectName
X->Y
Y does not ->X
Y->Z
{Book} ->{Author} (if we know the book, we knows the author name)
1. If X ⊇ Y then X → Y
Example:
1. X = {a, b, c, d, e}
2. Y = {a, b, c}
1. If X → Y then XZ → YZ
Example:
1. If X → Y and X → Z then X → YZ
Proof:
1. X → Y (given)
2. X → Z (given)
3. X → XY (using IR2 on 1 by augmentation with X. Where XX = X)
4. XY → YZ (using IR2 on 2 by augmentation with Y)
5. X → YZ (using IR3 on 3 and 4)
1. If X → YZ then X → Y and X → Z
Proof:
1. X → YZ (given)
2. YZ → Y (using IR1 Rule)
3. X → Y (using IR3 on 1 and 2)
1. If X → Y and YZ → W then XZ → W
Proof:
1. X → Y (given)
2. WY → Z (given)
3. WX → WY (using IR2 on 1 by augmenting with W)
4. WX → Z (using IR3 on 3 and 2)
Closures of a set of functional dependencies
A Closure is a set of FDs is a set of all possible FDs that can be derived from a given
set of FDs. It is also referred as a Complete set of FDs. If F is used to donate the set of
FDs for relation R, then a closure of a set of FDs implied by F is denoted by F+. Let's
consider the set F of functional dependencies given below:
Now, by applyiing Rule-6 Union, it is possible to derive A+ -> ABCD and it can be
denoted using A -> ABCD. All such type of FDs derived from each FD of F form a
closure of F. Steps to determine F+example:
Determine each set of attributes X that appears as a left hand side of some FD in
F.
Determine the set X+ of all attributes that are dependent on X, as given in above
example.
In other words, X+ represents a set of attributes that are functionally determined
by X based on F. And, X+ is called the Closure of X under F.
All such sets of X+, in combine, Form a closure of F.
Steps:
1. X+ = X //initialize X+ to X
2. For each FD : Y -> Z in F Do
If Y ⊆ X+ Then //If Y is contained in X+
X+ = X+ ∪ Z //add Z to X+
End If
End For
3. Return X+ //Return closure of X