Attribute Closure (X⁺)

 

๐Ÿ“˜ Attribute Closure (X⁺)

๐Ÿ”น Definition

For a set of attributes X, the closure of X (denoted X⁺) is:

The set of all attributes that can be functionally determined from X using the given functional dependencies (F).


Why Closure is Important

Attribute closure helps us:

  • ✅ Find all attributes determined by X
  • ✅ Check if X is a superkey / candidate key
  • ✅ Understand hidden relationships
  • ✅ Perform normalization

⚙️ Algorithm : Finding X⁺

๐Ÿ“Œ Input:

  • Set of FDs → F
  • Set of attributes → X

๐Ÿ”„ Steps of the Algorithm

1. Start with: X⁺ = X 2. Repeat: - For each FD (Y → Z) in F: If Y ⊆ X⁺: Add Z to X⁺ 3. Stop when: No new attributes are added

๐Ÿ’ก Key Idea

  • Start with what you know (X)
  • Keep adding attributes that can be derived
  • Stop when nothing new can be added

๐Ÿงพ Given Example: CLASS Relation

Relation:

CLASS (Classid, Course#, Instr_name, Credit_hrs, Text, Publisher, Classroom, Capacity)

๐Ÿ“Œ Functional Dependencies (F)

  1. FD1:

    Classid → Course#, Instr_name, Credit_hrs, Text, Publisher, Classroom, Capacity
  2. FD2:

    Course# → Credit_hrs
  3. FD3:

    {Course#, Instr_name} → Text, Classroom
  4. FD4:

    Text → Publisher
  5. FD5:

    Classroom → Capacity

๐Ÿ” Closure Calculations


๐Ÿ”น 1. Closure of {Classid}⁺

Step-by-step:

  • Start:

    X⁺ = {Classid}
  • Apply FD1:

    Classid → all attributes

✅ Result:

{Classid}⁺ = {Classid, Course#, Instr_name, Credit_hrs, Text, Publisher, Classroom, Capacity}

๐ŸŽฏ Interpretation:

  • Classid determines all attributes
  • ๐Ÿ‘‰ So, Classid is a candidate key

๐Ÿ”น 2. Closure of {Course#}⁺

Step-by-step:

  • Start:

    X⁺ = {Course#}
  • Apply FD2:

    Course# → Credit_hrs

✅ Result:

{Course#}⁺ = {Course#, Credit_hrs}

๐ŸŽฏ Interpretation:

  • Course# determines only Credit hours
  • ❌ Not a key
  • ❌ Cannot determine instructor, text, etc.

๐Ÿ”น 3. Closure of {Course#, Instr_name}⁺

Step-by-step:

  • Start:

    X⁺ = {Course#, Instr_name}
  • Apply FD3:

    → Text, Classroom
  • Apply FD4:

    Text → Publisher
  • Apply FD5:

    Classroom → Capacity
  • Apply FD2:

    Course# → Credit_hrs

✅ Final Result:

{Course#, Instr_name}⁺ = {Course#, Instr_name, Credit_hrs, Text, Publisher, Classroom, Capacity}

๐ŸŽฏ Interpretation:

  • Determines many attributes
  • ❌ But does NOT determine Classid

๐Ÿ‘‰ Therefore:

  • ❌ Not a candidate key

Key Takeaways

  • Closure (X⁺) = all attributes determined by X
  • Use algorithm iteratively
  • Helps identify:
    • Candidate keys
    • Redundant attributes
  • Interpretation gives real-world meaning

Comments

Popular posts from this blog

Database Management Systems DBMS PCCST402 Semester 4 KTU CS 2024 Scheme

Data Models, Schemas and Instances

Introduction to Database Management System -DBMS