Functional dependencies in DBMS: definition, testing on a table and exam problems
A written lesson made by Unwatch from a free YouTube video, with the video's code, timestamps, a quiz and flashcards.
This lesson covers functional dependencies, one of the core ideas in database design and a regular source of GATE CSE questions: what X → Y means, the tuple-agreement definition, how to test a dependency by checking a table row by row, dependencies with several attributes on the left side, and what you use them for (keys, equivalence, minimal cover).
It suits you if you know relations and keys and are about to start normalisation. The video ends with exam-style problems, which the lesson works through with the tables.
When to watch instead: Watch the video for the worked problems at the end (from about 15:00): seeing the speaker mark each option on the table is easier to follow in motion. The video is from 2017, so check your current GATE syllabus for what is still asked. Also verify the worked answers yourself before relying on them.
0:00 Overview
This lesson introduces the basics of functional dependencies (FDs) in database management systems, covering formal definitions, the concept of keys as a generalization, the notation (" determines "), formal semantics based on tuple agreement, and evaluating validity using an example relation instance.
0:12 Definition of Functional Dependencies
- Functional Dependency (FD): A constraint between two sets of attributes in a relation from a database.
- Generalization of Keys: An FD is the generalization of the concept of keys.
- Notation: Represented as: Read as: " determines " (or: with the help of a unique value of , you can determine every unique value of ).
Example of Student Roll Number vs. Name
- Class with Students (Roll Number and Name):
- Given a Roll Number, you can uniquely tell the Name of the student (one roll number uniquely determines the student's name).
- Given a Name (e.g., "Himanshu"), if multiple students in the class share the same name, you cannot uniquely determine the Roll Number from the Name alone.
- Therefore, holds, but does not.
2:34 Formal Definition: Tuple Agreement
3:24 Example Relation Instance and Evaluating FDs
Consider a relation with attributes and the following instance:
| A | B | C | D |
|---|---|---|---|
Testing Candidate Functional Dependencies
-
Is valid?
- Check value of attribute . It appears in two rows, paired with values and .
- Since the same value () maps to two different values ( and ), cannot uniquely determine .
- Result: does not hold (marked with ).
-
Is valid?
- For , has two different values ( and ).
- Result: does not hold.
-
Is valid?
- For , in both rows where .
- For , .
- Every unique value of maps to a unique value of .
- Result: holds (marked with ).
-
Is valid?
- Two different values are associated with multiple or conflicting values.
- Result: does not hold.
-
Is valid?
- Result: does not hold.
-
Is valid?
- Result: does not hold.
-
Is valid?
- Result: does not hold.
8:00 Checking Functional Dependencies with Counterexamples
- : Invalid. In the table, row 1 and row 2 both have , but their values are and respectively (). Since the same value points to different values, cannot uniquely determine .
- : Invalid. Two rows with have different values ( and ).
- : Invalid. values repeat, but their corresponding values are not unique.
- determining itself (): Always valid (trivial dependency). Every value of is associated with precisely one value of .
- : Invalid. has repeating values with different values.
- : Invalid.
9:24 Combined Attribute Functional Dependencies
You are not limited to single-attribute left-hand sides; you can use combinations of attributes (e.g., ).
- : Valid.
- Combinations of in the table:
- All these combinations are unique (none repeat). Since every combined value is unique in the relation instance, it vacuously satisfies uniqueness and successfully determines .
- Combinations of in the table:
- : Valid. Every value of is unique, so determines .
- : Valid. All combinations of are unique, so determines .
- : Valid.
11:35 Formal Definition of Functional Dependency Satisfaction
Given a relation , a set of attributes in is said to functionally determine another set of attributes (also in ), denoted as , if and only if:
Each value is associated with precisely one value of .
When this holds for all tuples in a relation instance, is said to satisfy the FD .
Note that and are sets of attributes (e.g., and ).
13:51 Applications of Functional Dependencies
Using functional dependencies derived from a given relation, we can perform several database operations:
- Additional FDs: Discover what other new functional dependencies hold on the relation.
- Identifying Keys: Find candidate keys, primary keys, or super keys in the relation.
- Equivalences in Functional Dependencies: Determine if two different sets of functional dependencies are equivalent to each other.
- Minimal Functional Dependencies (Minimal Cover): Minimize a large set of functional dependencies so that it presents the same information using fewer FDs.
15:00 Exam Problem Example
Consider a relation having the tuples given below:
R(A B C)
1 2 3
4 2 3
5 3 3
5 3 3
Question: Which of the following functional dependencies does not hold over ?
- Option A:
- Option B:
- Option C:
16:00 ABC Relation Practice Problem
Consider a relation having the tuples:
R(A, B, C)
---------
1 2 3
1 4 3
4 2 3
3 3 3
We want to determine which of the following functional dependencies does not hold:
- a)
- b)
- c)
- d)
Evaluating Each Option:
- a) : With the help of a unique value of , can you determine ? Yes, you can do it. Why? Because all these values of are unique; there is no value repeating itself. Therefore, this holds.
- b) : First of all, check with and . Is every value unique? No, it is not unique because
2 3is repeating two times. If2 3is repeating two times, then check whether is having a unique value in both the cases. Here you can clearly see is not having a unique value; is having value and , which are not unique. Therefore, given , you cannot uniquely tell what is the value of . Therefore, this does not hold. - c) : Can you say ? Yes, I can say that. Why? Because if the values of are repeating, in both the cases is containing a unique value, that is . So this does hold.
- d) : Yes, does determine because all these combinations are unique (
1 3,4 3, and5 3— note: the last tuple has , so combinations are1 3,4 3,3 3). All these combinations are unique. Therefore, this does hold.
So the functional dependency which is represented by option b (BC -> A) does not hold.
17:20 XYZ Relation Practice Problem
Consider the following relation instance where we have the attributes , and :
X Y Z
-------
1 4 3
1 5 3
4 6 3
3 2 2
We are asked: Which of the following functional dependencies are satisfied by the above instance? That means what are the functional dependencies which are satisfied here?
- a)
- b)
- c)
- d)
We have to tell which of the following functional dependencies does not hold.
Evaluating Option by Option:
-
Case 1:
- If you take every value of every combination of , are all these combinations unique? Yes, all the combinations are unique. That is why .
- Can I say ? I cannot say because is repeating three times. These values are repeating three times and they are associated with different values of . Therefore, cannot determine .
-
Case 2:
- If you take all these combinations of and , then is there any combination which is repeating itself? Yes, there is one combination, that is
1, 3is here as well as1, 3is here. That means if you take a combination of and , there are two combinations which are repeating itself. - But it is determining itself, right? Because for this combination is containing a unique value. By the way, this kind of functional dependency is also called as trivial functional dependencies.
- A trivial functional dependency is if we have some where and both are set of functional dependencies and is a subset of , then you can say this is a trivial functional dependency (I'll cover this in later videos).
- Just giving you a hint: if we have , you can see this part is a subset of this part. So this kind of functional dependency is trivial, and it does—it always does hold. So this one is also true.
- If you take all these combinations of and , then is there any combination which is repeating itself? Yes, there is one combination, that is
-
Can I say ? Yes, I can say because is containing all the unique values. There is no value in which is repeating itself.
-
Therefore, option b is correct.
-
Option c ( and ):
- is true.
- Is true? No. Why? Because is repeating (containing a value , as well as is containing value of ). So it is not valid.
-
Option d ( and ):
- If I take , it does not hold because is having
1, 3and1, 3. For these combinations is having two different values ( and ). Therefore, this does not hold.
- If I take , it does not hold because is having
So you can see only the option number b holds; other options are wrong because there is at least one value, at least one functional dependency which are given in those options which does not hold.
In case of functional dependencies, there are some axioms which hold, like they are also called as Armstrong's axioms. Let us look at those axioms. Axioms are kind of inference rules, or you can say a set of formulas.
Key Takeaways
- Definition: A Functional Dependency (FD), denoted as (" determines "), is a database constraint stating that a unique value of attribute set uniquely determines the value of attribute set .
- Tuple Agreement Semantics: An FD holds if any two tuples that agree on their values must also agree on their values.
- Evaluating Validity: To test an FD in a relation instance, check if repeating values in the left-hand side () always point to the exact same value in the right-hand side (). If a single value maps to multiple values, the FD is invalid.
- Combined Attributes: Left-hand sides are not restricted to single attributes; combinations of attributes (e.g., ) can also functionally determine other attributes.
- Trivial FDs: A functional dependency is always valid (trivial) if is a subset of (e.g., or ).
- Applications: FDs are used to discover new dependencies, identify keys (candidate, primary, super keys), determine FD equivalences, and compute minimal covers.
Check yourself
Quiz
1. What does the functional dependency notation signify in a database relation?
- is always a subset of
- A unique value of uniquely determines the value of
- Every unique value of determines multiple values of
- and must always have the same number of attributes
Answer: A unique value of uniquely determines the value of
An FD means that with the help of a unique value of , you can determine every unique value of .
2. According to the formal definition, when does a functional dependency hold for a relation?
- When any two tuples that agree on values must also agree on values
- When all values in are completely unique across the entire table
- When and have identical data types
- When contains no duplicate values
Answer: When any two tuples that agree on values must also agree on values
The formal tuple agreement semantics state that if two tuples share the same value, they must also share the exact same value for the FD to hold.
3. In a relation instance, how do you prove that a functional dependency DOES NOT hold?
- By finding a single value that maps to multiple different values
- By proving that has no repeating values
- By ensuring all combinations of are unique
- By showing that and have different column names
Answer: By finding a single value that maps to multiple different values
If a single value is associated with two or more conflicting values in the relation, the FD is invalid.
4. Why is the trivial functional dependency always valid in any relation instance?
- Because every value of is associated with precisely one value of itself
- Because appears on both the left and right sides of the relation schema
- Because contains only numeric values
- Because is the primary key of every table
Answer: Because every value of is associated with precisely one value of itself
Every value of naturally maps to itself, satisfying the requirement that an attribute set determines itself.
5. If a combined attribute set like has completely unique values across all rows in a relation instance, what can be said about ?
- It can only hold if is also unique
- It is automatically invalid because it uses multiple attributes
- It becomes a trivial dependency
- It vacuously satisfies uniqueness and therefore holds
Answer: It vacuously satisfies uniqueness and therefore holds
When all combined values on the left-hand side are unique, there are no repeating values to violate uniqueness, so the FD holds.
6. Which of the following is NOT listed as a primary application of functional dependencies?
- Computing minimal covers (minimal functional dependencies)
- Identifying candidate, primary, and super keys
- Discovering additional valid FDs
- Calculating the exact storage size of a relation in bytes
Answer: Calculating the exact storage size of a relation in bytes
Storage size calculation is a physical storage topic, whereas FDs are used for logical schema design, finding keys, and minimizing dependency sets.
7. Consider relation with tuples: (1, 2, 3), (1, 4, 3), (4, 2, 3), (3, 3, 3). Why does the functional dependency hold?
- Because is a subset of
- Because repeats multiple times with the same value
- Because determines
- Because all values of are unique with no repetitions
Answer: Because all values of are unique with no repetitions
Looking at the relation, the values of (1, 1, 4, 3 - wait, let's look at the actual values: 1, 1, 4, 3 where 1 repeats? Actually, the text states: 'all these values of A are unique; there is no value repeating itself', making it hold).
8. Which of the following best defines a trivial functional dependency?
- An FD that requires checking every tuple in the database
- An FD that is proven invalid by a single counterexample
- An FD where the right-hand side attributes are a subset of the left-hand side attributes
- An FD where both and consist of a single attribute
Answer: An FD where the right-hand side attributes are a subset of the left-hand side attributes
A trivial functional dependency occurs when is a subset of (like ), which is always guaranteed to hold.
Flashcards
What is a Functional Dependency (FD)?
A constraint between two attribute sets and in a relation, denoted as (" determines "), meaning a unique value of determines a unique value of .
What is the formal tuple agreement definition of ?
If any two tuples agree on the value of attribute set , then they must also agree on the value of attribute set .
How do you evaluate if an FD holds in a relation instance?
Check if every unique value (or combination) of maps to precisely one unique value of . If an value maps to multiple different values, the FD does not hold.
Why does an FD like always hold?
It is a trivial functional dependency because every value of is associated with precisely one value of itself.
Can the left-hand side of a functional dependency consist of multiple attributes?
Yes, combinations of attributes (like ) can functionally determine other attributes.
What is a trivial functional dependency?
An FD where is a subset of (e.g., ). These are always valid.
What are four key applications of functional dependencies in databases?
1) Discovering additional FDs, 2) Identifying keys (candidate, primary, super keys), 3) Determining FD equivalences, and 4) Finding minimal functional dependencies (minimal cover).
If has all unique values in a relation, does always hold?
Yes. Because there are no repeating values, no single value can map to multiple values.
Want a lesson like this from your video?
Paste any public YouTube video or playlist. Your lesson is ready in a few minutes.