What is a super key in database management?

Introduction

A super key is a collection of all keys that can uniquely identify rows of a table. It is a superset of all possible composite keysA unique Identifier formed by combining more than one attribute of a relation and candidate keysA collection of all attributes that can uniquely Identify a tuple in a relation..

In a relational DBMSDatabase Management System:

  • A table is referred to as a relation.
  • A row is a tuple.
  • Columns are known as attributes.

How to get the super keys of a relation

The table below shows an example of a relation.

A products relation

product_no

product_name

product_type

6000yt

splizer300

washer machine

3425r

junes34

standing fan

4530h

junes34

toaster

3545k

hydrator

washer machine

4578j

splizer300

washer machine

Using the products relation above, we can perform the steps below to get the super keys of the relation.

Step 1

List all sets of possible attributes combinations from the table, as shown below:

  • {product_no}

  • {product_name}

  • {product_type}

  • {product_no,product_name}

  • {product_no,product_type}

  • {product_name,product_type}

  • {product_no,product_name,product_type}

Step 2

Next, from the list above, remove all combinations that are not in compliance with the super key requirement. This requirement simply entails that there cannot be the same attribute value for distinct tuples.

Simply put, this step will require that you identify all candidate keys and all composite keys from the list you made in step 1, and eliminate the ones that do not fall under this category.

With regards to our products relation example, the combination {product_name, product_type} will be eliminated, because the two distinct tuples below could exist.

  • {6000yt,splizer300, washer machine}

  • {4578j,splizer300, washer machine}

Similarly, the {product name} and {product type} columns will be eliminated because they are not unique.

Step 3

Finally, make a list of the super keys we have identified. The breakdown of the list is as follows:

  • {product_no}: (A candidate key)

  • {product_no,product_name}: (A composite key)

  • {product_no,product_type}: (A composite key)

  • {product_no,product_name,product_type}: (A composite key)

For our example, the list of super keys is shown below.

Super keys

{product_no}

{product_no,product_name}

{product_no,product_type}

{product_no,product_name,product_type}

Free Resources