Attribute Closure (X⁺)

Attribute Closure of a set X is the set of all attributes that can be determined from X using functional dependencies.

πŸ‘‰ X⁺ = all attributes that X can determine (direct + indirect)

Formula: X⁺ = { A | X β†’ A }

🎯 Why Attribute Closure is Important?

πŸ‘‰ If X⁺ contains all attributes β†’ X is a Super Key

Learn more about Super Key

βš™οΈ Steps to Find Attribute Closure

  1. Start with X⁺ = X
  2. Check all Functional Dependencies
  3. If LHS βŠ† X⁺ β†’ add RHS
  4. Repeat until no change occurs
πŸ‘‰ Continue until closure stops growing

πŸ“Š Example (GATE Level)

R(A, B, C, D, E)
F = { A β†’ BC, B β†’ D, CD β†’ E }

A⁺ = {A}
β†’ {A, B, C}
β†’ {A, B, C, D}
β†’ {A, B, C, D, E}

Final: A⁺ = {A, B, C, D, E}

πŸ‘‰ A is a Super Key

πŸ“Š Attribute Closure Example (GATE Level)

Given Functional Dependencies:

F = { A β†’ B, C β†’ D, AB β†’ E, BE β†’ C, EF β†’ G } ---

🎯 Goal

Find the following closures:

---

βš™οΈ Step-by-Step Rule

πŸ‘‰ Start with given attributes β†’ keep adding new attributes using FDs until no change
---

πŸ” Find A⁺

Start: A⁺ = {A} A⁺ = {A, B}

No more dependencies can be applied

πŸ‘‰ A⁺ = {A, B}
---

πŸ” Find AF⁺

Start: AF⁺ = {A, F} AF⁺ = {A, F, B, E, C, D, G}
πŸ‘‰ AF⁺ = {A, B, C, D, E, F, G}
---

πŸ” Find AE⁺

Start: AE⁺ = {A, E} AE⁺ = {A, E, B, C, D}
πŸ‘‰ AE⁺ = {A, B, C, D, E}
---

πŸ” Find CD⁺

Start: CD⁺ = {C, D} CD⁺ = {C, D}

No new attribute can be added

πŸ‘‰ CD⁺ = {C, D}
---

πŸ’£ Final Answer

πŸ‘‰ AF⁺ gives all attributes β†’ AF is a candidate key

Learn more about Candidate Key

🧠 Key Observations

❌ Common Mistakes

Prime and Non-Prime Attributes (Deep Concept)

In DBMS, attributes are classified based on their participation in candidate keys. This concept is extremely important for normalization (2NF, 3NF, BCNF).

1. Prime Attribute

A prime attribute is any attribute that is part of at least one candidate key.

πŸ‘‰ If an attribute appears in ANY candidate key β†’ it is PRIME

Example 1

πŸ‘‰ Prime Attributes = A, B, C

⚠️ Important: Even if an attribute appears in only one candidate key, it is still PRIME.

2. Non-Prime Attribute

A non-prime attribute is an attribute that is NOT part of any candidate key.

πŸ‘‰ If attribute is NOT in any candidate key β†’ NON-PRIME

Example 2

πŸ‘‰ Prime = A, B
πŸ‘‰ Non-Prime = C, D

πŸ”₯ Tricky GATE Concept

If a relation has multiple candidate keys, then all attributes appearing in any candidate key are PRIME.

πŸ‘‰ Prime = A, B, C πŸ‘‰ Non-Prime = None

πŸ’‘ GATE Trick: If all attributes are part of some candidate key β†’ No non-prime attributes

Relation with Functional Dependency

Functional Dependency helps identify candidate keys, and candidate keys determine prime attributes.

πŸ”₯ Role in Normalization

➑️ Second Normal Form (2NF)

A relation is in 2NF if:

πŸ‘‰ Partial dependency = Non-prime depends on part of key

➑️ Third Normal Form (3NF)

A relation is in 3NF if:

πŸ‘‰ X β†’ Y allowed if Y is PRIME

πŸ“Š GATE-Level Question Example

Relation: R(A, B, C, D) FD: A β†’ B, B β†’ C

Step 1: Find candidate key πŸ‘‰ A+ = A, B, C β†’ Not complete πŸ‘‰ Add D β†’ (A, D) is candidate key

πŸ‘‰ Prime = A, D πŸ‘‰ Non-Prime = B, C

Difference Table

Prime Attribute Non-Prime Attribute
Part of candidate key Not part of candidate key
Used in normalization rules Causes dependency issues
Helps identify records Stores extra data
πŸš€ Final Shortcut: Candidate Key ke andar β†’ PRIME Candidate Key ke bahar β†’ NON-PRIME

πŸš€ Continue Learning

Practice and Test your knowledge:

πŸ‘‰Practice Questions β†’

πŸ”— Related Topics