What is Super Key? Is it different from Composite Key?

Super Key:

A super key is a set of one or more attributes (columns) that, taken together, can uniquely identify a record within a table. In other words, it is a superset of a candidate key. A candidate key is a minimal set of attributes that can uniquely identify a record, and a super key may include additional attributes beyond what is necessary for uniqueness.

Example:

Consider a table representing employees with attributes (columns) such as EmployeeID, FirstName, LastName, and SocialSecurityNumber. A super key could be {EmployeeID, SocialSecurityNumber}, as this combination uniquely identifies each employee. However, it is not a candidate key because we can achieve the same uniqueness with just {EmployeeID} or {SocialSecurityNumber}.

Composite Key:

A composite key, on the other hand, is a specific type of super key that consists of two or more attributes (columns) that together uniquely identify a record. Unlike a super key, a composite key is not a superset of another key; it is a distinct key formed by combining multiple attributes for uniqueness.

Difference:

  • The main difference lies in the relationship between super keys and candidate keys:
  • A super key is any set of attributes that uniquely identifies a record, and it may include more attributes than necessary for uniqueness.
  • A composite key is a specific kind of super key formed by combining two or more attributes, and it is unique in itself.

Example:

In the case of the employees table, {EmployeeID, SocialSecurityNumber} is a super key, and it is also a composite key because it is formed by combining two attributes.

In summary, while a super key is a broader concept representing any set of attributes that uniquely identifies a record, a composite key is a specific type of super key formed by combining multiple attributes for uniqueness.