Functional Dependencies in DBMS

1. What is Functional Dependency (FD)?

πŸ‘‰ A relationship where one column (or set of columns) determines another.

  • Example: Roll_No β†’ Name (Knowing Roll_No gives Name).

2. Key Terms

  • Determinant = the predictor (e.g., Roll_No).
  • Dependent = the predicted (e.g., Name).

3. Why FD is Important?

βœ” Removes redundancy
βœ” Prevents anomalies (update/insert/delete problems)
βœ” Helps normalize tables


4. Types of FD

  • Trivial: {A, B} β†’ A (dependent is part of determinant).
  • Non-Trivial: A β†’ B (dependent not part of determinant).

5. Keys & Closure

  • Candidate Key = Smallest set of columns that uniquely identify rows.
    Example: Roll_No.
  • Closure = All attributes you can find from a key.
    Example: Roll_No⁺ = {Roll_No, Name, Class}.

6. Why Decompose Tables?

Bad tables cause:

  • Redundancy (wasted space).
  • Update anomaly (change in many rows).
  • Insert anomaly (can’t add data without another).
  • Delete anomaly (deleting one row loses other info).

7. How to Decompose?

  • Lossless decomposition β†’ No data is lost when splitting.
  • Dependency preservation β†’ FDs still hold in decomposed tables.

8. Normal Forms (NF)

  • 1NF β†’ No repeating groups, atomic values.
  • 2NF β†’ No partial dependency (non-key column depends on part of key).
  • 3NF β†’ No transitive dependency (non-key depends on another non-key).
  • BCNF β†’ Every determinant must be a candidate key.

9. Steps to Solve FD Questions

  1. Find candidate keys.
  2. Find FDs.
  3. Check normal form (1NF β†’ 2NF β†’ 3NF β†’ BCNF).
  4. Decompose if needed (lossless + dependency preserved).

10. Easy Memory Trick πŸš€

FD = If I know this β†’ I know that

Keys unlock the table

Normalize step by step:

BCNF β†’ Determinant must be a key

1NF β†’ Remove repeating data

2NF β†’ Remove partial dependency

3NF β†’ Remove transitive dependency