Attribute Sets

A set of attributes.

Closure

Suppose XX is an attribute set and FF is a set of functional dependencies.

Closure of XX under a set of functional dependencies FF, is the set of all attributes functionally determined by XX using the dependencies in FF. Denoted as X+X^+,

Algorithm

X+X^+ can be computed by:

  1. Start with X+=XX^+ = X.
  2. For each dependency Y→ZY \rightarrow Z in FF:
    If Y⊆X+Y \subseteq X^+, then add ZZ to X+X^+.
  3. Repeat until no new attributes can be added.

If X+X^+ includes all attributes of RR, then XX is a superkey of RR.

Can be used to test if a given functional dependency holds.

def attribute_closure(attributes, fds):
    """
    Compute the closure of a set of attributes with respect to a set of functional dependencies.

    :param attributes: set of attribute strings, e.g. {'A', 'B'}
    :param fds: list of tuples (lhs, rhs), where lhs and rhs are sets of attributes
                e.g. [({'A'}, {'B'}), ({'B'}, {'C'})]
    :return: set of attributes in the closure
    """
    closure = set(attributes)
    changed = True
    while changed:
        changed = False
        for lhs, rhs in fds:
            if lhs.issubset(closure) and not rhs.issubset(closure):
                closure.update(rhs)
                changed = True
    return closure

Extraneous Attributes

Unnecessary attributes in a functional dependency (FD) that can be removed without affecting the closure. Can either be in LHS or RHS.

Removing extraneous attributes:

  • Simplifies functional dependency sets
  • Helps compute minimal covers
  • Avoids redundant checks during normalization

Testing

Consider a set of functional dependencies FF, and α→β∈F\alpha \rightarrow \beta \in F.

The attribute A∈αA \in \alpha is extraneous in α\alpha if (α−A)+(\alpha - A)^+ contains β\beta.

The attribute A∈βA \in \beta is extraneous in β\beta if:

  • Compute α+\alpha^+ using only the dependencies in F′=(F−{ α→β })∪(α→(β−A))F' = (F - \set{\alpha \rightarrow \beta}) \cup (\alpha \rightarrow (\beta - A))
  • Check if α+\alpha^+ contains AA. If it does, AA is extraneous in β\beta

Examples

Attribute in the LHS.

Given F={ A→C,AB→C }F = \set{A \rightarrow C, AB \rightarrow C}. Test BB in AB→CAB \rightarrow C.

Solution Reveal Hide
  • α=AB\alpha = AB and β=C\beta = C
  • (α−B)+=A+={ A,C }(\alpha - B)^+ = A^+ = \set{A, C} using A→CA \rightarrow C
  • A+A^+ contains β=C\beta = C, so BB is extraneous
  • AB→CAB \rightarrow C reduces to A→CA \rightarrow C

Attribute in the RHS.

Given F={ A→B,B→C,A→BC }F = \set{A \rightarrow B, B \rightarrow C, A \rightarrow BC}. Test CC in A→BCA \rightarrow BC.

Solution Reveal Hide
  • α=A\alpha = A and β=BC\beta = BC
  • F′={ A→B,B→C,A→B }F' = \set{A \rightarrow B, B \rightarrow C, A \rightarrow B}
  • A+={ A,B,C }A^+ = \set{A, B, C} in F′F', using A→BA \rightarrow B then B→CB \rightarrow C
  • A+A^+ contains CC, so CC is extraneous
  • A→BCA \rightarrow BC reduces to A→BA \rightarrow B
Written by October 19, 2026 2 min read
Was this helpful?