📊

Understanding Functional Dependency in Databases

Sep 21, 2024

Functional Dependency Lecture Notes

Introduction

  • Topic: Functional Dependency
  • Context: Understanding normal forms (1NF, 2NF, 3NF, BCNF)
  • Reminder: Covered normalization and denormalization in previous lectures.

Definition of Functional Dependency

  • Functional dependency describes the relationship between attributes in a relation (table).
  • Example from math: If y = f(x) (e.g., y = x² + 2x + 1), then y is functionally dependent on x.

Key Concepts

  • Attributes: Columns in a table.
  • Relation: A table in a database.
  • Functional Dependency: If knowing the value of x allows us to determine the value of y, then y is functionally dependent on x.
  • Not limited to single attributes; can involve sets of attributes.
  • Primary Key: A unique identification key, which can be a single or composite attribute.
  • Determinant: The attribute (or set of attributes) that can uniquely determine another attribute.

Examples

  • In a table with attributes Roll Number and Name:

    • If Roll Number is known, Name can be determined, thus Name is functionally dependent on Roll Number.
  • Table Example:

    Employee IDFirst NameLast Name
    1RiaSingh
    1RahulKumar
    • Here, Employee ID does not uniquely determine First Name because multiple names correspond to the same ID.

Identifying Functional Dependencies

  • For a relation with attributes x and y, if x determines y, then for any two records with the same value of x, the corresponding values of y must be the same.
  • If duplicates exist in the Employee ID, check whether values of First Name and Last Name are consistent for the same ID.

Properties of Functional Dependency (Inference Rules)

  1. Reflexivity: If Y is a subset of X, then X determines Y.
  2. Augmentation: If X determines Y, then X, Z determines Y, Z for any Z.
  3. Transitivity: If X determines Y and Y determines Z, then X determines Z.
  4. Union: If X determines Y and X determines Z, then X determines Y, Z.
  5. Decomposition: If X determines Y, Z, then X determines Y and X determines Z.

Types of Functional Dependency

  • Trivial Functional Dependency: X determines Y is trivial if Y is a subset of X. Example: Employee ID determines Employee ID.
  • Non-Trivial Functional Dependency: X determines Y is non-trivial if Y is not a subset of X. Example: Employee Name determining Employee ID needs to be verified by checking the data table.

Conclusion

  • Summary of functional dependency and its importance in understanding database normalization.
  • Encouragement to follow the channel for more content and to engage with the material.