# Functional Dependencies Database

In order to design a good database Functional Dependencies in Database is an important concept. In order to ensure the integrity of data and a good performance of a database functional dependencies plays an important role. Definition of Functional Dependency on Wikipedia HERE.

Suppose we have a relation in database where there are only two attributes X and Y:

Functional Dependency Def.

X –> Y

if t1.X = t2.X then t1.Y = t2.Y

Is there a functional dependency in above table? To find about it look at values in X which are same. in X the 2nd row and last row has same X value = 2 . In order to satisfy the second argument check for Y values too. The Y value for 2nd row = a and the Y value for last row is = d. where t1.y != t2.y . So the functional dependency not holds in above table.

#### Large table with more attributes

Suppose We have x as sid and y as name. Does x has functional dependency with y? Look at the values in x are there any same values. All the values in sid are unique so it has functional dependency with name.

We can even take x as composite keys. Suppose x is cid and room and y is grade. Does x has a functional dependency with y? Look at all the values in x are there any same values? Row 1, 3 and 5 are having same values. so first condition is met t1.x = t2.x. Look for there y values. Row 1 and 3 x values have same y values. Now check Row 1 with Row 4. Row 1 and Row 4 have different Y values. Row 1 has Y value A. And Row 4 has Y value = C. Thus the second condition t1.y = t2.y does not met so x has not a functional dependency with y.

Databases related posts Visit HERE

Python-related posts Visit HERE

C++ related posts Visit HERE

Data Structures related posts visit HERE

Algorithms related posts visit HERE

Data Science related posts visit HERE

Share the Knowledge