What is a functional dependency in DBMS?
A functional dependency X -> Y means that if two rows have the same X value they must have the same Y value, so X determines Y. Normalization is built on finding and organizing these dependencies.
Explain it simply
A roll number determines a student's name: once you know the roll number, the name is fixed. The reverse is not true, since two students may share a name. We write this as roll_no -> name, read as "roll_no determines name".
Example
Table enrolment(roll_no, name, course_id, course_name, marks).
Dependencies that hold:
roll_no -> namecourse_id -> course_name(roll_no, course_id) -> marks
The marks depend on the pair: a student has different marks in different courses, so neither column alone determines it.
Types you should name:
- Trivial:
{roll_no, name} -> name, where the right side is part of the left. - Partial: a non-key column depends on only part of a composite key, such as
roll_no -> nameabove. This breaks 2NF. - Transitive: A -> B and B -> C, so A -> C through a non-key B. This breaks 3NF.
Functional dependencies come from real-world rules, not from today's data. A table that happens to show no duplicates does not prove a dependency.
What to say in the interview
"X -> Y means X uniquely determines Y. Candidate keys are the minimal sets that determine every column. Partial and transitive dependencies on non-key columns are what 2NF and 3NF remove."
Common mistakes
- Inferring a dependency from sample rows instead of from business rules.