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

5 Marchfunctionaldependency

Functional dependency is when one attribute determines another attribute in a database. There are different types of functional dependencies: - Trivial dependency occurs when an attribute determines itself or a subset of attributes it belongs to. - Non-trivial dependency occurs when an attribute determines another attribute that is not a subset of itself. - Multivalued dependency occurs when two attributes are dependent on a third attribute but independent of each other. - Transitive dependency indirectly occurs through two other dependencies, such as X determining Z through X determining Y and Y determining Z.

Uploaded by

ashutosh kumar
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)
40 views

5 Marchfunctionaldependency

Functional dependency is when one attribute determines another attribute in a database. There are different types of functional dependencies: - Trivial dependency occurs when an attribute determines itself or a subset of attributes it belongs to. - Non-trivial dependency occurs when an attribute determines another attribute that is not a subset of itself. - Multivalued dependency occurs when two attributes are dependent on a third attribute but independent of each other. - Transitive dependency indirectly occurs through two other dependencies, such as X determining Z through X determining Y and Y determining Z.

Uploaded by

ashutosh kumar
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/ 10

What is a functional dependency?

Functional Dependency is when one attribute determines another attribute in a DBMS


system. Functional Dependency plays a vital role to find the difference between good
and bad database design.

Example:

Employee number Employee Name Salary City

1 Dana 50000 San Francisco

2 Francis 38000 London

3 Andrew 25000 Tokyo


In this example, if we know the value of Employee number, we can obtain Employee Name, city, salary,
etc.
By this, we can say that the city, Employee Name, and salary are functionally depended on Employee
number.
A functional dependency is denoted by an arrow →
The functional dependency of X on Y is represented by X →Y

Rules of Functional Dependencies


Below given are the Three most important rules for Functional Dependency:
 Reflexive rule –. If X is a set of attributes and Y is_subset_of X, then X holds a value of Y.
 Augmentation rule: When x -> y holds, and c is attribute set, then ac -> bc also holds. That is
adding attributes which do not change the basic dependencies.
 Transitivity rule: This rule is very much similar to the transitive rule in algebra if x -> y holds and
y -> z holds, then x -> z also holds. X -> y is called as functionally that determines y.
Types of Functional Dependencies
 Trivial functional dependency:
 Non-trivial functional dependency:
 Multivalued dependency:
 Transitive dependency:
Trivial Functional dependency:
Example 1
The Trivial dependency is a set of attributes which are called a trivial if the set of attributes are included
in that attribute.
So, X -> Y is a trivial functional dependency if Y is a subset of X.
For example:

Emp_id Emp_name

AS555 Harry

AS811 George

AS999 Kevin
Consider this table with two columns Emp_id and Emp_name.
{Emp_id, Emp_name} -> Emp_id is a trivial functional dependency as Emp_id is a subset of
{Emp_id,Emp_name}.

Example 2

The dependency of an attribute on a set of attributes is known as trivial functional


dependency if the set of attributes includes that attribute.
Symbolically: A ->B is trivial functional dependency if B is a subset of A.

The following dependencies are also trivial: A->A & B->B

For example: Consider a table with two columns Student_id and Student_Name.

{Student_Id, Student_Name} -> Student_Id is a trivial functional dependency as


Student_Id is a subset of {Student_Id, Student_Name}. That makes sense because if we
know the values of Student_Id and Student_Name then the value of Student_Id can be
uniquely determined.

Also, Student_Id -> Student_Id & Student_Name -> Student_Name are trivial
dependencies too.
Non trivial functional dependency in DBMS
Functional dependency which also known as a nontrivial dependency occurs when A->B holds true where
B is not a subset of A. In a relationship, if attribute B is not a subset of attribute A, then it is considered as
a non-trivial dependency.

Company CEO Age

Microsoft Satya Nadella 51

Google Sundar Pichai 46

Apple Tim Cook 57


Example 3:
(Company} -> {CEO} (if we know the Company, we knows the CEO name)
But CEO is not a subset of Company, and hence it's non-trivial functional dependency.

Example 4

If a functional dependency X->Y holds true where Y is not a subset of X then this
dependency is called non trivial Functional dependency.
For example:
An employee table with three attributes: emp_id, emp_name, emp_address.
The following functional dependencies are non-trivial:
emp_id -> emp_name (emp_name is not a subset of emp_id)
emp_id -> emp_address (emp_address is not a subset of emp_id)

On the other hand, the following dependencies are trivial:


{emp_id, emp_name} -> emp_name [emp_name is a subset of {emp_id, emp_name}]

Completely non trivial FD:


If a FD X->Y holds true where X intersection Y is null then this dependency is said to be
completely non trivial function dependency.
Multivalued dependency in DBMS
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.
Example 5:

Car_model Maf_year Color

H001 2017 Metallic

H001 2017 Green

H005 2018 Metallic

H005 2018 Blue

H010 2015 Metallic

H033 2012 Gray


In this example, maf_year and color are independent of each other but dependent on car_model. In this
example, these two columns are said to be multivalue dependent on car_model.
This dependence can be represented like this:
car_model -> maf_year
car_model-> colour
Example 6:
When existence of one or more rows in a table implies one or more other rows in the same table, then the
Multi-valued dependencies occur.

If a table has attributes P, Q and R, then Q and R are multi-valued facts of P.


It is represented by double arrow:
->->

For our example:


P->->Q
P->->R

In the above case, Multivalued Dependency exists only if Q and R are independent attributes.
A table with multivalued dependency violates the 4NF.
Example

Let us see an example:


<Student>
StudentName CourseDiscipline Activities

Amit Mathematics Singing

Amit Mathematics Dancing

Yuvraj Computers Cricket

Akash Literature Dancing

Akash Literature Cricket

Akash Literature Singing

In the above table, we can see Students Amit and Akash have interest in more than one activity.
This is multivalued dependency because CourseDiscipline of a student are independent of Activities, but are
dependent on the student.
Therefore, multivalued dependency:
StudentName ->-> CourseDiscipline
StudentName ->-> Activities

The above relation violates Fourth Normal Form in Normalization.


To correct it, divide the table into two separate tables and break Multivalued Dependency:

<StudentCourse>
StudentName CourseDiscipline

Amit Mathematics

Amit Mathematics

Yuvraj Computers

Akash Literature
Akash Literature

Akash Literature

<StudentActivities>
StudentName Activities

Amit Singing

Amit Dancing

Yuvraj Cricket

Akash Dancing

Akash Cricket

Akash Singing

This breaks the multivalued dependency and now we have two functional dependencies:
StudentName -> CourseDiscipline
StudentName - > Activities

Example 7

If an attribute X uniquely determines an attribute Y, then Y is functionally dependent on X. This


is written as X -> Y. For example, in the Students table below, the Student_Name determines the
Major:

Student_Name Major

Ravi Art History

Beth Chemistry

This functional dependency can be written: Student_Name -> Major. Each Student_Name
determines exactly one Major and no more.
If you want the database to also track the sports these students take, you might think the easiest
way to do this is to just add another column titled Sport:

Student_Name Major Sport

Ravi Art History Soccer

Ravi Art History Volleyball

Ravi Art History Tennis

Beth Chemistry Tennis

Beth Chemistry Soccer

The problem here is that both Ravi and Beth play multiple sports. It is necessary to add a new
row for every additional sport.
This table has introduced a multivalued dependency because the major and the sport are
independent of one another but both depend on the student. This is a simple example and easily
identifiable, but a multivalue dependency could become a problem in a large, complex database.

A multivalued dependency is written X ->-> Y. In this case:


Student_Name ->-> Major
Student_Name ->-> Sport
This is read as "Student_Name multidetermines Major" and "Student_Name multidetermines
Sport."
A multivalued dependency always requires at least three attributes because it consists of at least
two attributes that are dependent on a third.
Transitive dependency:
A transitive is a type of functional dependency which happens when t is indirectly formed by two
functional dependencies.
Example 8:

Company CEO Age

Microsoft Satya Nadella 51

Google Sundar Pichai 46

Alibaba Jack Ma 54
{Company} -> {CEO} (if we know the compay, we know its CEO's name)
{CEO } -> {Age} If we know the CEO, we know the Age
Therefore according to the rule of rule of transitive dependency:
{ Company} -> {Age} should hold, that makes sense because if we know the company name, we can
know his age.
Note: You need to remember that transitive dependency can only occur in a relation of three or more
attributes.
Example 9:
A functional dependency is said to be transitive if it is indirectly formed by two functional dependencies.
For e.g.

X -> Z is a transitive dependency if the following three functional dependencies hold true:

X->Y
Y does not ->X
Y->Z
Note: A transitive dependency can only occur in a relation of three of more attributes. This dependency
helps us normalizing the database in 3NF (3rd Normal Form).
Example 10: Let’s take an example to understand it better:

Book Author Author_age

Game of Thrones George R. R. Martin 66

Harry Potter J. K. Rowling 49

Dying of the Light George R. R. Martin 66

{Book} ->{Author} (if we know the book, we knows the author name)

{Author} does not ->{Book}

{Author} -> {Author_age}

Therefore as per the rule of transitive dependency: {Book} -> {Author_age} should
hold, that makes sense because if we know the book name we can know the author’s age.

Example 11
AUTHORS
Author_ID Author Book Author_Nationality

Auth_001 Orson Scott Card Ender's Game United States

Auth_001 Orson Scott Card Ender's Game United States

Auth_002 Margaret Atwood The Handmaid's Tale Canada

In the AUTHORS example above:


Book → Author: Here, the Book attribute determines the Author attribute. If you know
the book name, you can learn the author's name. However, Authordoes not
determine Book, because an author can write multiple books. For example, just because
we know the author's name Orson Scott Card, we still don't know the book name.
Author → Author_Nationality: Likewise, the Author attribute determines
the Author_Nationality, but not the other way around; just because we know the
nationality does not mean we can determine the author.
But this table introduces a transitive dependency:
Book →Author_Nationality: If we know the book name, we can determine the
nationality via the Author column.

Advantages of Functional Dependency


 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

You might also like