5 Marchfunctionaldependency
5 Marchfunctionaldependency
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
For example: Consider a table with two columns Student_id and Student_Name.
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.
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)
In the above case, Multivalued Dependency exists only if Q and R are independent attributes.
A table with multivalued dependency violates the 4NF.
Example
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
<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
Student_Name Major
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:
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.
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} (if we know the book, we knows the author name)
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