Unwatch › Sample lessons › Functional dependencies (DBMS)

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.

Based on the video: “Functional Dependencies | DBMS 15 | GATE CSE” by Himanshu Kaushik | Computer Science & AI (21 min). Licensed CC BY 3.0 (YouTube Creative Commons). This lesson is an AI-made adaptation by Unwatch, not made or endorsed by Himanshu Kaushik | Computer Science & AI. About 10 min to read.

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 X→Y ("X determines Y"), 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: X→Y Read as: "X determines Y" (or: with the help of a unique value of X, you can determine every unique value of Y).

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, Roll Number→Name holds, but Name→Roll Number does not.

2:34 Formal Definition: Tuple Agreement

X→Y says that if two tuples agree on the value of attribute X, then they must also agree on the value in attribute Y.


3:24 Example Relation Instance and Evaluating FDs

Consider a relation with attributes A,B,C,D and the following instance:

A B C D
a1 b1 c1 d1
a1 b2 c2 d1
a2 b2 c1 d2
a3 b3 c2 d2
a4 b4 c4 d4
a5 b3 c3 d3

Testing Candidate Functional Dependencies

  1. Is A→B valid?

    • Check value a1 of attribute A. It appears in two rows, paired with B values b1 and b2.
    • Since the same A value (a1) maps to two different B values (b1 and b2), A cannot uniquely determine B.
    • Result: A→B does not hold (marked with ×).
  2. Is A→C valid?

    • For A=a1, C has two different values (c1 and c2).
    • Result: A→C does not hold.
  3. Is A→D valid?

    • For A=a1, D=d1 in both rows where A=a1.
    • For A=a3, D=d2.
    • Every unique value of A maps to a unique value of D.
    • Result: A→D holds (marked with ✓).
  4. Is B→A valid?

    • Two different B values are associated with multiple or conflicting A values.
    • Result: B→A does not hold.
  5. Is B→C valid?

    • Result: B→C does not hold.
  6. Is B→D valid?

    • Result: B→D does not hold.
  7. Is C→A valid?

    • Result: C→A does not hold.

8:00 Checking Functional Dependencies with Counterexamples

  • C→B: Invalid. In the table, row 1 and row 2 both have C=c1, but their B values are b1 and b2 respectively (b1≠b2). Since the same C value points to different B values, C cannot uniquely determine B.
  • C→D: Invalid. Two rows with C=c1 have different D values (d1 and d2).
  • D→A: Invalid. D values repeat, but their corresponding A values are not unique.
  • D determining itself (D→D): Always valid (trivial dependency). Every value of D is associated with precisely one value of D.
  • D→B: Invalid. D has repeating values with different B values.
  • D→C: 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., AB).

  • AB→C: Valid.
    • Combinations of AB in the table:
      • a1b1
      • a1b2
      • a2b2
      • a3b3
      • a4b4
      • a5b3
    • All these combinations are unique (none repeat). Since every combined AB value is unique in the relation instance, it vacuously satisfies uniqueness and successfully determines C.
  • AB→D: Valid. Every value of A is unique, so AB determines D.
  • BC→A: Valid. All combinations of BC are unique, so BC determines A.
  • BC→D: Valid.

11:35 Formal Definition of Functional Dependency Satisfaction

Given a relation R, a set of attributes X in R is said to functionally determine another set of attributes Y (also in R), denoted as X→Y, if and only if:

Each X value is associated with precisely one value of Y.

When this holds for all tuples in a relation instance, R is said to satisfy the FD X→Y.

Note that X and Y are sets of attributes (e.g., X={A,B} and Y={C,D}).


13:51 Applications of Functional Dependencies

Using functional dependencies derived from a given relation, we can perform several database operations:

  1. Additional FDs: Discover what other new functional dependencies hold on the relation.
  2. Identifying Keys: Find candidate keys, primary keys, or super keys in the relation.
  3. Equivalences in Functional Dependencies: Determine if two different sets of functional dependencies are equivalent to each other.
  4. 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 R(A,B,C) 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 R?

  • Option A: A→B
  • Option B: BC→A
  • Option C: B→C

16:00 ABC Relation Practice Problem

Consider a relation R(A,B,C) 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) A→B
  • b) BC→A
  • c) B→C
  • d) AC→B

Evaluating Each Option:

  • a) A→B: With the help of a unique value of A, can you determine B? Yes, you can do it. Why? Because all these values of A are unique; there is no value repeating itself. Therefore, this holds.
  • b) BC→A: First of all, check with B and C. Is every value unique? No, it is not unique because 2 3 is repeating two times. If 2 3 is repeating two times, then check whether A is having a unique value in both the cases. Here you can clearly see A is not having a unique value; A is having value 1 and 4, which are not unique. Therefore, given BC, you cannot uniquely tell what is the value of A. Therefore, this does not hold.
  • c) B→C: Can you say B→C? Yes, I can say that. Why? Because if the values of B are repeating, in both the cases C is containing a unique value, that is 3. So this does hold.
  • d) AC→B: Yes, AC does determine B because all these combinations are unique (1 3, 4 3, and 5 3 — note: the last tuple has A=3,B=3,C=3, so combinations are 1 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 X,Y, and Z:

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) XY→Z,Z→Y
  • b) XZ→X,Y→Z
  • c) XY→Z,Z→X
  • d) XZ→Y,Y→Z

We have to tell which of the following functional dependencies does not hold.

Evaluating Option by Option:

  • Case 1: XY→Z

    • If you take every value of every combination of XY, are all these combinations unique? Yes, all the combinations are unique. That is why XY→Z.
    • Can I say Z→Y? I cannot say Y because Z is repeating three times. These values are repeating three times and they are associated with different values of Y. Therefore, Z cannot determine Y.
  • Case 2: XZ→X

    • If you take all these combinations of X and Z, then is there any combination which is repeating itself? Yes, there is one combination, that is 1, 3 is here as well as 1, 3 is here. That means if you take a combination of X and Z, there are two combinations which are repeating itself.
    • But it is determining X itself, right? Because for this combination X 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 X→Y where X and Y both are set of functional dependencies and Y is a subset of X, 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 ABC→AB, 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.
  • Can I say Y→Z? Yes, I can say Y→Z because Y is containing all the unique values. There is no value in Y which is repeating itself.

  • Therefore, option b is correct.

  • Option c (XY→Z and Z→X):

    • XY→Z is true.
    • Is Z→X true? No. Why? Because 3 is repeating (containing a value 1, as well as 3 is containing value of 4). So it is not valid.
  • Option d (XZ→Y and Y→Z):

    • If I take XZ→Y, it does not hold Y because XZ is having 1, 3 and 1, 3. For these combinations Y is having two different values (4 and 5). Therefore, this does not hold.

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 X→Y ("X determines Y"), is a database constraint stating that a unique value of attribute set X uniquely determines the value of attribute set Y.
  • Tuple Agreement Semantics: An FD X→Y holds if any two tuples that agree on their X values must also agree on their Y values.
  • Evaluating Validity: To test an FD in a relation instance, check if repeating values in the left-hand side (X) always point to the exact same value in the right-hand side (Y). If a single X value maps to multiple Y values, the FD is invalid.
  • Combined Attributes: Left-hand sides are not restricted to single attributes; combinations of attributes (e.g., AB→C) can also functionally determine other attributes.
  • Trivial FDs: A functional dependency X→Y is always valid (trivial) if Y is a subset of X (e.g., D→D or ABC→AB).
  • 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 X→Y signify in a database relation?
  1. Y is always a subset of X
  2. A unique value of X uniquely determines the value of Y
  3. Every unique value of Y determines multiple values of X
  4. X and Y must always have the same number of attributes

Answer: A unique value of X uniquely determines the value of Y
An FD X→Y means that with the help of a unique value of X, you can determine every unique value of Y.

2. According to the formal definition, when does a functional dependency X→Y hold for a relation?
  1. When any two tuples that agree on X values must also agree on Y values
  2. When all values in X are completely unique across the entire table
  3. When X and Y have identical data types
  4. When Y contains no duplicate values

Answer: When any two tuples that agree on X values must also agree on Y values
The formal tuple agreement semantics state that if two tuples share the same X value, they must also share the exact same Y value for the FD to hold.

3. In a relation instance, how do you prove that a functional dependency X→Y DOES NOT hold?
  1. By finding a single X value that maps to multiple different Y values
  2. By proving that X has no repeating values
  3. By ensuring all combinations of XY are unique
  4. By showing that X and Y have different column names

Answer: By finding a single X value that maps to multiple different Y values
If a single X value is associated with two or more conflicting Y values in the relation, the FD is invalid.

4. Why is the trivial functional dependency D→D always valid in any relation instance?
  1. Because every value of D is associated with precisely one value of itself
  2. Because D appears on both the left and right sides of the relation schema
  3. Because D contains only numeric values
  4. Because D is the primary key of every table

Answer: Because every value of D is associated with precisely one value of itself
Every value of D naturally maps to itself, satisfying the requirement that an attribute set determines itself.

5. If a combined attribute set like AB has completely unique values across all rows in a relation instance, what can be said about AB→C?
  1. It can only hold if C is also unique
  2. It is automatically invalid because it uses multiple attributes
  3. It becomes a trivial dependency
  4. 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 X values to violate uniqueness, so the FD holds.

6. Which of the following is NOT listed as a primary application of functional dependencies?
  1. Computing minimal covers (minimal functional dependencies)
  2. Identifying candidate, primary, and super keys
  3. Discovering additional valid FDs
  4. 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 R(A,B,C) with tuples: (1, 2, 3), (1, 4, 3), (4, 2, 3), (3, 3, 3). Why does the functional dependency A→B hold?
  1. Because A is a subset of B
  2. Because A repeats multiple times with the same B value
  3. Because B determines C
  4. Because all values of A are unique with no repetitions

Answer: Because all values of A are unique with no repetitions
Looking at the relation, the values of A (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?
  1. An FD that requires checking every tuple in the database
  2. An FD that is proven invalid by a single counterexample
  3. An FD where the right-hand side attributes are a subset of the left-hand side attributes
  4. An FD where both X and Y 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 Y is a subset of X (like ABC→AB), which is always guaranteed to hold.

Flashcards

What is a Functional Dependency (FD)?

A constraint between two attribute sets X and Y in a relation, denoted as X→Y ("X determines Y"), meaning a unique value of X determines a unique value of Y.

What is the formal tuple agreement definition of X→Y?

If any two tuples agree on the value of attribute set X, then they must also agree on the value of attribute set Y.

How do you evaluate if an FD X→Y holds in a relation instance?

Check if every unique value (or combination) of X maps to precisely one unique value of Y. If an X value maps to multiple different Y values, the FD does not hold.

Why does an FD like D→D always hold?

It is a trivial functional dependency because every value of D 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 AB→C) can functionally determine other attributes.

What is a trivial functional dependency?

An FD X→Y where Y is a subset of X (e.g., ABC→AB). 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 A has all unique values in a relation, does A→B always hold?

Yes. Because there are no repeating A values, no single A value can map to multiple B values.

Want a lesson like this from your video?

Paste any public YouTube video or playlist. Your lesson is ready in a few minutes.