Docsity

DBMS Notes: Functional Dependencies, Armstrong’s Axioms & Normalization, Study notes of Computer science

Toggle sidebar
bg1
1. Functional Dependencies (FD)
A functional dependency is a constraint between two attributes (or sets of attributes)
in a relation. An attribute Y is functionally dependent on attribute X if each value of
X uniquely determines exactly one value of Y.
• Notation: FD: X → Y (read as “X determines Y” or “Y is functionally dependent
on X”)
• X is called the determinant, Y is called the dependent.
• FDs help distinguish good database design from bad design by exposing
redundancy.
Rule for checking an FD
For any two tuples t1, t2 in a relation, if t1.X = t2.X, then t1.Y must equal t2.Y. If
every value of the determinant is unique, the dependency automatically holds.
Example — Student table
Stud_ID → Stud_Name
Since Stud_ID uniquely identifies a student, it determines the name.
Example — Employee table (StudentID, Name, Department, DeptHead)
• StudentID → Name, Department, DeptHead (StudentID is the key, so it
determines everything else)
• Department → DeptHead (each department has exactly one head)
• Name ↛ StudentID (a name doesn't uniquely determine the ID, since two
people can share a name)
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download DBMS Notes: Functional Dependencies, Armstrong’s Axioms & Normalization and more Study notes Computer science in PDF only on Docsity!

1. Functional Dependencies (FD)

A functional dependency is a constraint between two attributes (or sets of attributes) in a relation. An attribute Y is functionally dependent on attribute X if each value of X uniquely determines exactly one value of Y.

  • Notation: FD: X → Y (read as “X determines Y” or “Y is functionally dependent on X”)
  • X is called the determinant, Y is called the dependent.
  • FDs help distinguish good database design from bad design by exposing redundancy.

Rule for checking an FD

For any two tuples t1, t2 in a relation, if t1.X = t2.X, then t1.Y must equal t2.Y. If every value of the determinant is unique, the dependency automatically holds.

Example — Student table

Stud_ID → Stud_Name

Since Stud_ID uniquely identifies a student, it determines the name.

Example — Employee table (StudentID, Name, Department, DeptHead)

  • StudentID → Name, Department, DeptHead (StudentID is the key, so it determines everything else)
  • Department → DeptHead (each department has exactly one head)

• Name ↛ StudentID (a name doesn't uniquely determine the ID, since two

people can share a name)

2. Types of Functional Dependency

A. Trivial Functional Dependency

  • A dependency X → Y is trivial if Y is a subset of X.
  • X → X and Y → Y are always trivial.

Example: For Student(Stud_ID, Stud_Name):

{Stud_ID, Stud_Name} → Stud_ID — trivial

B. Non-Trivial Functional Dependency

  • A dependency X → Y is non-trivial if Y is NOT a subset of X.

Example (Employee table):

Emp_ID → Emp_Name, Emp_ID → Emp_Address, {Emp_ID, Emp_Name} →

Emp_Name

Completely Non-Trivial FD

If X → Y holds and the intersection of X and Y is empty (null), it is called a completely non-trivial functional dependency.

C. Multivalued Functional Dependency

  • Occurs when there is more than one independent multivalued attribute in a table.
  • Notation: X →→ Y (X multidetermines Y)

Example (Bike table with Model, Manuf_year, Color):

Model →→ Manuf_year Model →→ Color

Manuf_year and Color are independent of each other but both depend on Model.

4. Armstrong's Axioms (Properties of FDs)

a) Reflexive Rule

If Y is a subset of X, then X → Y.

Example: For Student(Roll_No, Name, Branch):

{Roll_No, Name} → Name (Name is already part of the left-hand side)

b) Augmentation Rule

If X → Y holds, and Z is any attribute set, then XZ → YZ also holds (adding attributes doesn't change the basic dependency).

Example:

Roll_No → Name ⇒ Roll_No, Branch → Name, Branch

c) Transitivity Rule

If X → Y and Y → Z hold, then X → Z also holds.

Example:

Roll_No → Dept_ID and Dept_ID → Dept_Name ⇒ Roll_No → Dept_Name

5. Advantages of Functional Dependency

  • Avoids data redundancy (same data isn't repeated at multiple places)
  • Helps maintain data quality
  • Helps define the meaning and constraints of a database
  • Helps identify bad designs
  • Helps uncover facts about the database design

6. Normalization — Overview

Normalization is a multi-step process used to eliminate data redundancy and enhance data integrity in tables by organizing columns and tables so that dependencies are properly enforced.

  • It decomposes tables to eliminate: data redundancy, insertion anomaly, update anomaly, and deletion anomaly.

Atomic Domain

An attribute's domain is atomic if its values are indivisible units (no multivalued or composite substructure).

Attribute Relation Atomicity Emp_Name Employee Atomic Emp_Age Employee Atomic Marks Student Atomic Phone_no Employee Non-atomic Name (Fname, Minit, Lname) Student Non-atomic

7. Anomalies in a Database

Problems caused by redundant data (duplicated data fields across multiple records).

a) Insertion Anomaly

Occurs when you cannot insert a new piece of information without also having some unrelated piece of information available.

Example: A new course “Cyber Security” cannot be added to a combined Student-Course table until a student actually enrolls in it, because the table requires Student_ID and Student_Name to be filled in.

8. Types of Normalization (Normal Forms)

First Normal Form (1NF)

Rule: A relation is in 1NF if it does not contain any multivalued or composite attributes — every attribute must hold only a single atomic (indivisible) value.

Example — Before (violates 1NF)

Roll Name Subject 19 Rajesh Math, Science 23 Supriya History, English 32 Zack Geography

Example — After (1NF, atomic values only)

Roll Name Subject 19 Rajesh Math 19 Rajesh Science 23 Supriya History 23 Supriya English 32 Zack Geography

Keys (needed for 2NF / 3NF)

Candidate Key

A set of one or more attributes that can uniquely identify a record in a relation. Any candidate key can be chosen as the primary key.

Super Key

A set of one or more attributes that can uniquely identify a record; a candidate key is a minimal super key, and the primary key is a subset of the super key.

Second Normal Form (2NF)

Rule: A relation is in 2NF if:

  • It is already in 1NF, and
  • It has no partial dependency.

What is partial dependency?

  • A functional dependency X → Y is a full functional dependency if removing any single attribute A from X causes the dependency to no longer hold (i.e., (X − {A}) does not determine Y).
  • A functional dependency X → Y is a partial dependency if some attribute A in X can be removed and X → Y still holds (i.e., for some A in X, (X − {A}) → Y).
  • Partial dependency can only happen when the relation has a composite primary key, and a non-key attribute depends on only part of that key rather than the whole key.

Transitive Dependency (recap): X → Z holds indirectly because X → Y and Y → Z (where Y does not → X).

  • 3NF reduces data duplication and helps achieve data integrity.

Example (violates 3NF)

Stud_id Name Sub_id Subject Address 11 Akshay C101 DS Mumbai 12 Kaushik C201 DBMS Pune 13 Satyajeet C105 AOA Satara 14 Niharika C204 TCS Pune 15 Rashmi C201 DBMS Pune Here: Stud_id → Sub_id, and Sub_id → Subject, therefore Stud_id → Subject transitively — this violates 3NF.

Decomposition to achieve 3NF

Student table:

Stud_id Name Sub_id Address 11 Akshay C101 Mumbai 12 Kaushik C201 Pune 13 Satyajeet C105 Satara 14 Niharika C204 Pune

Subject_details table:

Sub_id Subject C101 DS C201 DBMS C105 AOA C204 TCS

Boyce-Codd Normal Form (BCNF)

Also known as 3.5NF.

Rule: A relation is in BCNF if:

  • It is already in 3NF, and
  • Every determinant (left-hand side attribute) of every functional dependency is a super key of that relation.

BCNF addresses certain anomalies not handled by 3NF.

Example (violates BCNF)

Subject relation — each student can enroll in multiple subjects, multiple teachers can teach the same subject, and for each subject a teacher is assigned:

Stud_id Subject Teacher 11 DS S. Tare 12 DBMS M. Kore 12 CN J. Patil 13 DBMS M. Kore 14 TCS K. Singh 14 DBMS M. Kore 15 CN J. Patil This is in 3NF but not BCNF, because there's an additional dependency: Teacher → Subject (Teacher is not a super key, yet it determines Subject).

Decomposition to achieve BCNF

Student table:

Stud_id Prof_id 11 101 12 102 12 103 13 102 14 104 14 102 15 103

9. Advantages of Normalization

  • Efficiently removes redundant data
  • Improves data quality and flexibility in database design
  • Improves overall organization of data
  • Keeps data consistent and logically stored

10. Worked Normalization Example (UNF → BCNF)

Starting (Unnormalized) table

StudentID StudentName Course Instructor 1 Alex DBMS, Networks Prof. Smith 2 Mary DBMS Prof. Smith 3 John Networks, Python Prof. Clark

Step 1 — 1NF (remove repeating groups, atomic values only)

StudentID StudentName Course Instructor 1 Alex DBMS Prof. Smith 1 Alex Networks Prof. Smith 2 Mary DBMS Prof. Smith 3 John Networks Prof. Clark 3 John Python Prof. Clark

Step 2 — 2NF (remove partial dependency)

Composite key is (StudentID, Course), but StudentName depends only on StudentID — split it out.

  • Student table: StudentID, StudentName
  • Enrollment table: StudentID, Course, Instructor

Step 3 — 3NF (remove transitive dependency)

Instructor depends on Course, not directly on StudentID — split further.

  • Student: StudentID, StudentName
  • Course_Instructor: Course, Instructor
  • Enrollment: StudentID, Course

Step 4 — BCNF (check every determinant is a super key)

Check: StudentID → StudentName ✓(StudentID is a super key), Course → Instructor ✓ (Course is a super key of that table). No violations — the three-table decomposition above is already in BCNF.

11. Decomposition and Dependency Preservation

Decomposition is the process of splitting a relation into two or more smaller relations to eliminate redundancy and anomalies.

Why decompose?

  • Ensures the database satisfies higher normal forms (e.g., BCNF, 3NF)
  • Helps preserve functional dependencies while maintaining data consistency

Goals of a good decomposition

  • Lossless-Join Property: A decomposition is lossless if joining the decomposed relations back together reproduces the original relation exactly (no spurious or lost tuples).
  • Dependency Preservation: A decomposition is dependency-preserving if all functional dependencies from the original relation can still be enforced/verified using the decomposed relations, without needing to join them back together.
  • Normalization: The decomposed relations should each be in an appropriate normal form.

Algorithm for Decomposition Using Functional Dependencies

Step 1: Identify the relation

R(Student_ID, Student_Name, Dept_ID, Dept_Name)

Step 2: Identify Functional Dependencies

F = { Student_ID → Student_Name, Dept_ID ; Dept_ID → Dept_Name }

Step 3: Find the Candidate Key (via attribute closure)

  • Student_ID⁺ = {Student_ID}

Multivalued Dependency (MVD)

Exists when one attribute determines a set of values for another attribute, independently of any other attributes in the relation.

  • Notation: X →→ Y (X multidetermines Y) means Y's set of values depends only on X, not on any other attribute.

Example: In relation Person, PersonID →→ PhoneNumbers means each person has an associated set of phone numbers, independent of other attributes.

Fourth Normal Form (4NF)

Rule: A relation is in 4NF if:

  • It is in BCNF, and
  • It has no non-trivial multivalued dependencies.

Decomposing into 4NF removes unnecessary duplication caused by multivalued dependencies.

Steps of decomposition for 4NF

    1. Identify the multivalued dependency.
    1. Separate the attributes into two or more relations so the multivalued attributes are represented independently.
    1. Ensure each new relation is itself in 4NF (no further multivalued dependencies).

Worked Example

Initial relation: Person(PersonID, Address, PhoneNumber) — a person can have multiple addresses AND multiple phone numbers, causing redundancy when both are stored together in one row.

Multivalued dependencies:

PersonID →→ Address PersonID →→ PhoneNumber

Decomposed relations:

  • Person_Address(PersonID, Address)
  • Person_Phone(PersonID, PhoneNumber)

This decomposition removes the redundancy that existed when addresses and phone numbers were combined in a single table.

13. Join Dependencies and Fifth Normal Form (5NF) —

Concept Only

Fifth Normal Form (5NF), also called PJNF (Project-Join Normal Form):

Rule: A relation is in 5NF if:

  • It is in BCNF, and
  • It has no join dependency (i.e., it cannot be decomposed into smaller tables without losing information, other than through a lossless multi-way join).
  • 5NF is the most advanced/highest level of database normalization covered here.
  • It resolves join dependency issues and further reduces data redundancy.
  • It also helps fix update anomalies in database design.