๐Ÿ“Š

Understanding Functional Dependency in Databases

Sep 1, 2024

Lecture Notes on Functional Dependency

Introduction to Functional Dependency

  • Definition: Functional dependency (FD) indicates a relationship between two attributes, typically between a key (determinant) and another attribute (dependent).
  • Importance: Understanding FDs is crucial for normalization in database design. If FDs are not clear, grasping normalization concepts will be difficult.

Key Concepts

  • Notation: Represented as X โ†’ Y, meaning X determines Y.
  • Determinant: The attribute on the left side (X) that identifies the value of the dependent attribute (Y).
  • Dependent: The attribute on the right side (Y) whose value is determined by the determinant (X).

Examples of Functional Dependency

  • Simple Example: If we have a relation R with attributes X and Y:
    • If X = 2 corresponds to Y = 1 in one row and Y = 5 in another, we cannot say X determines Y (not FD).
    • If X = 2 always corresponds to Y = 1, then X determines Y (FD exists).

Rules for Checking Functional Dependency

  1. If two tuples have the same value for the determinant, they must have the same value for the dependent attribute for FD to hold.
  2. If the values of the determinant are different, the values of the dependent attribute can be ignored for FD check.

Example Analysis

  1. Case with Unique Values: If all values of X are unique, then X determines Y.
  2. Case with Repetition: If X has repetitions:
    • Check the corresponding values of Y. If they differ for the same X, FD does not hold.
    • If they are the same, then FD exists.

Practical Example with Student Relation

  • Attributes: Roll Number, Name, Marks, Department, Course
  • Check for Functional Dependencies:
    • Roll Number โ†’ Name: True, because roll numbers are unique.
    • Name โ†’ Roll Number: Not FD, since names can repeat.
    • Roll Number โ†’ Marks: True, as roll numbers are unique.
    • Department โ†’ Course: Not FD, since a department can offer multiple courses.
    • Course โ†’ Department: Not FD, as one course may belong to different departments.
    • Combination of attributes can also be checked for FDs.

Summary of Findings

  • FDs must be evaluated based on the attributes' uniqueness and their corresponding values.
  • For complex attributes, combinations can also be defined as determinants.
  • Repetition in determinants leads to checks on dependent attributes to confirm or deny FDs.

Conclusion

  • Understanding functional dependency is foundational for successful database normalization.
  • Future discussions will include types of functional dependencies and Armstrongโ€™s axioms.

Practice Problems

  • The lecturer encourages the audience to practice identifying FDs from provided relations or examples and share findings.