What is functional dependency? Explain with Example.
Function Dependency: A functional dependency is a relationship between two attributes. It means that if the value of one attribute is known, it is possible to obtain the value of another attribute.
Suppose there is a relation STUDENT with following fields:
STUDENT (registrationNo, StudentName, Class, Email)
Is value of RegistrationNo is known, it is possible to obtain the value of StudentName. It means that studentName is functionally dependent of registrationNo. An attribute B is functionally dependent on attribute A if the value of A determines the value of B.
RegistrationNo → StudentName
The above expression means RegistrationNo determines StudeName or Student Name is functionally dependent on RegistrationNo. The attribute on left side is called determinant.
An attribute can also be functionally dependent on two or more attributes instead of a single attribute. The attribute CRSDATE is functionally dependent on both STUID and COURSE (STUID, CRSNO, CRSDATE)
The functional dependency in the relation is represented as follows:
STUDID, CRSNO → CRSDATE
The course completion date CRSDATE can be determined only if both STUID and CRSNO are known. No single attribute can be used to determine CRSDATE.