Functional Dependency
Introduction
- Functional Dependency describes the relationship between attributes in a table.
- It represents how one attribute determines another.
- General format: X → Y means X determines Y, or Y is determined by X.
- X: Determinant attribute (main attribute)
- Y: Dependent attribute
Example
- SID → S.name
- If SID is unique, it removes the confusion about names.
- E.g., Two students named Ranjit with SIDs 1 and 2 are differentiated using their SIDs.
- If SIDs are the same, it indicates the same student; if different, they are different students.
Four Possible Cases
-
Case 1: Same SIDs and names (e.g., Ranjit, Ranjit with SID 1, SID 1)
- Valid case: Mistake in data entry, same student.
-
Case 2: Different SIDs but same names (e.g., Ranjit, Ranjit with SID 1, SID 2)
- Valid case: Different students with the same name.
-
Case 3: Different SIDs and different names (e.g., Ranjit, Varun with SIDs 1 and 2)
- Valid case: Different students.
-
Case 4: Same SID but different names (e.g., Ranjit, Varun with SID 1, SID 1)
- Invalid case: Contradiction, SID 1 cannot determine both Ranjit and Varun.
Types of Functional Dependencies
-
Trivial Dependency
- Format: X → Y where Y is a subset of X (e.g., SID → SID).
- Always valid.
- Reflects the reflexive property (attribute determining itself).
-
Non-trivial Dependency
- Format: X → Y where Y is not a subset of X (e.g., SID → S.name).
- Requires checking cases for validity.
Properties of Functional Dependencies
-
Reflexivity: If Y is a subset of X, then X → Y (always valid, reflects trivial dependency).
-
Augmentation: If X → Y, then XZ → YZ (adding additional attributes to both sides).
-
Transitivity: If X → Y and Y → Z, then X → Z (used frequently).
-
Union: If X → Y and X → Z, then X → YZ.
-
Decomposition: If X → YZ, then X → Y and X → Z (valid for right-hand side).
- Note: Cannot decompose the left-hand side (e.g., XY → Z cannot be decomposed to X → Z and Y → Z).
-
Pseudo Transitivity: If X → Y and WY → Z, then WX → Z.
-
Composition: If X → Y and Z → W, then XZ → YW.
Important: Transitive and reflexive properties are used frequently. In decomposition, do not break the left-hand side. Validity must be checked in non-trivial dependencies.
Conclusion
- Valid, invalid cases and properties important for exams.
- Understanding functional dependencies helps in database management.
- Like, comment, and subscribe for more content.