Super Key in DBMS

A Super Key in DBMS is a set of one or more attributes (columns) in a table that can uniquely identify a tuple (record) in that table by its attribute or combination of attributes.

Here are key points about Super Key in DBMS:

Super Key in DBMS

  • The super set of any candidate key is a super key (i.e., a candidate key is always a subset of a super key).
  • More than one candidate key can exist for a super key.
  • Every candidate key is a super key, but not every super key is a candidate key.
  • Super keys can include unnecessary attributes beyond what is needed for uniqueness.
  • They play a crucial role in ensuring data integrity and are used in relational database design.

Key Characteristics of Super Key in DBMS

Here are the key characteristics of a super key in DBMS

Key characteristics of Super Key in DBMS

1. Uniqueness

A super key uniquely identifies each tuple (row) in a table. No two rows can have the same values for the attributes included in the super key.

Example: If ID is unique, then {ID} is a super key.

2. Combination of Attributes

A super key can contain one attribute or multiple attributes together. The combined values must uniquely identify each row.

Example: {ID, Name} can be a super key if ID alone is unique.

3. Candidate Key is Compulsory

Every super key must contain at least one candidate key because a candidate key is the minimum attribute set required to uniquely identify a tuple. Without including a candidate key, uniqueness cannot be guaranteed. We can also say that candidate key is always a subset of a super key

Example: If {ID} is a candidate key, then {ID} and {ID, Name} can be super keys, but {Name} alone cannot be a super key if it is not unique.

4. May Include Extra Attributes

A super key can have additional attributes that are not required for uniqueness. These extra attributes make the key non-minimal.

Example: {ID, Salary} is a super key if ID alone is enough to identify rows.

5. Multiple Super Keys Possible

A single relation can have many super keys because different attribute combinations may uniquely identify tuples.

Example: {ID}, {ID, Name}, and {ID, Email} can all be super keys.

6. Supports Normalization

Super keys help determine functional dependencies, which are used in normalization to reduce redundancy and improve database design.

Example: Knowing {ID} → Name, Salary helps during normalization.

Now we will see various examples of super key calculations over the given candidate keys and attributes

Category – 1: Finding Super Key in DBMS Using a Single Candidate Key

Finding the super keys in DBMS depends on how many candidate keys exist in the relation (R). If the relation (R) has “n” attributes and only a single candidate key, then superkeys can be calculated using the following formula

  • Super keys = 2n-k

where

  • “n” represents all the attributes in the relation
  • “k” represents the length of the candidate key

The following diagram gives some examples for finding superkeys when a relation R with “n” attributes and the candidate key with “k” length is given

Finding Super Keys in DBMS Using a Single Candidate Key

Let’s explain some examples of finding super keys over single candidate key of length “K”

Finding Super Key in DBMS Example 1:

Suppose

  • A relation R(A, B) represents a table with two attributes. Therefore, n=2.
  •  There is a single candidate key, which is {A}, whose length is 1. Therefore, K =1

Using the diagram below, calculate all super keys from the given data.

   Finding Super Keys in DBMS Example - 01Finding Super Key in DBMS Example 2:

Suppose

  • A relation R(A, B, C) represents a table with three attributes. Therefore, n=3.
  •  There is a single candidate key which {A}, whose length is 1. Therefore, K =1

Using the diagram below, calculate all super keys from the given data.

Finding Super Keys in DBMS Example - 02

Finding Super Key in DBMS Example 3:

Suppose

  • A relation R(A, B, C, D) represents a table with four attributes. Therefore, n=4.
  •  There is a single candidate key which {A}, whose length is 1. Therefore, K =1

Using the diagram below, calculate all super keys from the given data.

Finding Super Keys in DBMS Example - 03

Finding Super Key in DBMS Example 4:

Suppose

  • A relation R(A, B, C) represents a table with three attributes. Therefore, n=3.
  •  There is a single candidate key which {A,B}, whose length is 2. Therefore, K =2

Using the diagram below, calculate all super keys from the given data.

Finding Super Keys in DBMS Example - 04

Finding Super Key in DBMS Example 5:

Suppose

  • A relation R(A, B, C, D, E) represents a table with five attributes. Therefore, n=5.
  •  There is a single candidate key which {A,B,C}, whose length is 3. Therefore, K =3

Using the diagram below, calculate all super keys from the given data.

Finding Super Keys in DBMS Example - 05

Finding Super Key in DBMS Example 6:

Suppose

  • A relation R(A, B, C, D, E) represents a table with three attributes. Therefore, n=5.
  •  There is a single candidate key which {A,B,C,D,E}, whose length is 5. Therefore, K =5

Using the diagram below, calculate all super keys from the given data.

Finding Super Keys in DBMS Example - 06

Category – 2:  Finding Super Key in DBMS Using a Multiple Candidate Keys, each of Same Length

When a relation contains several candidate keys. Each candidate key can generate many superkeys. If we add super keys produced by each candidate key, some super keys may appear in more than one group. Therefore, duplicates occur. The Inclusion–Exclusion Principle removes these duplicate counts.

According to the Inclusion–Exclusion Principle

  • Total Super Keys = (Sum of single candidate-key counts) − (Sum of pair overlaps) + (Sum of triple overlaps) − (Sum of quadruple overlaps) + …

Simply, we can write as well

Pattern: Singles − Pairs + Triples − Quadruples + Quintuples − Sextuples + Septuples − Octuples + …

So, we can say that Odd-numbered groups are added (+), and even-numbered groups are subtracted (−). Let’s discuss some examples where multiple candidate keys exist.

Finding Super Key in DBMS – Example 7

To calculate the super keys of example 7, the following data is given

  • A relation R(A, B, C) represents a table with three attributes. Therefore, n=3.
  •  There are two candidate keys {A}, {B}, each of length 1.

Using the diagram below, calculate all super keys from the given data.

Finding Super Keys in DBMS Example - 07

Let’s explain the above example 7 in the following steps

Step 01: Understanding the Formula

The formula is divided into two different parts based on the number of candidate keys combined.

Super Keys Formula Understanding Example - 07 - updated

In the above diagram

Part 1: Count super keys formed from single candidate keys

  • + 2n-1 + 2n-1

Part 2: Subtract super keys formed from pair candidate-key overlaps

  • − 2n-2

Step 02: Single Candidate Keys to Super Keys 

  • For the candidate key {A}, every super key must contain A. After fixing A, the remaining attributes B and C can be added in different combinations. Therefore, {A} generates (23-1 = 4) super keys: {A}, {A,B}, {A,C}, {A,B,C}.
  • For the candidate key {B}, every super key must contain B. After fixing B, the remaining attributes A and C can be added in different combinations. Therefore, {B} generates (23-1=4) super keys: {B}, {A,B}, {B,C}, {A,B,C}.

Note: Some super keys like {A,B} and {A,B,C} appear in both candidate key lists of {A} and {B}. So, they are counted twice. To fix this, we will subtract them once in the next step when we use the pair candidate key {A,B}.

Finding Super Keys Using Single Candidate Keys - Example 07

Step 03: Single to Pair Candidate Keys Conversions Process 

To get the pair candidate key from {A} and {B}, simply combine both candidate keys into one set: {A} + {B} = {A,B}

Single to Pair Candidate Keys Conversions - Example 07

Step 04: Pair Candidate Keys to Super Keys 

The candidate key {A} generates some super keys, and the candidate key {B} also generates some super keys. Some of these super keys are the same because they contain both A and B. Therefore, these common super keys are counted twice.

To find these common super keys, combine {A} and {B} to form pair candidate key {A,B} which generates (23-2 =2 ) common super keys as given below

  • {A, B}
  • {A, B, C}

Since these two super keys appear in both the {A} list and the {B} list, they must be subtracted once to get the correct total number of super keys.

Finding Super Keys Using Pair Candidate Keys - Example 07

Finding Super Key in DBMS Example 8:

To calculate the super keys of example 8, the following data is given

  • A relation R(A, B, C, D) represents a table with four attributes. Therefore, n=4.
  •  There are three candidate keys {A}, {B}, {C} each of length 1.

Using the diagram below, calculate all super keys from the given data.

Finding Super Keys in DBMS Example - 08 - updated

Let’s explain the above example 8 in the following steps

Step 01: Understanding the Formula 

The formula is divided into three different parts based on the number of candidate keys combined.

Super Keys Formula Understanding Example - 08

In the above diagram

Part 1: Count super keys formed from single candidate keys

  • + 2n-1 + 2n-1 + 2n-1

Part 2: Subtract super keys formed from pair candidate-key overlaps

  • − 2n-2 − 2n-2 − 2n-2

Part 3: Add super keys formed from triple candidate-key overlaps

  • + 2n-3

Step 02: Single Candidate Keys to Super Keys 

For candidate key {A}: All super keys must contain

  • {A}, {A,B}, {A,C}, {A,D}, {A,B,C}, {A,B,D}, {A,C,D}, {A,B,C,D}

For candidate key {B}:

All super keys must contain B

  • {B}, {A,B}, {B,C}, {B,D}, {A,B,C}, {A,B,D}, {B,C,D}, {A,B,C,D}

For candidate key {C}:

All super keys must contain C

  • {C}, {A,C}, {B,C}, {C,D}, {A,B,C}, {A,C,D}, {B,C,D}, {A,B,C,D}

Finding Super Keys Using Single Candidate Keys - Example 08

Step 03: Single to Pair Candidate Keys Conversions Process 

Pair candidate keys are formed as: {A, B}, {A, C}, {B, C} over single candidate keys {A}, {B}, and {C}. The following diagram shows it

Single to Pair Candidate Keys Conversions - Example 08

Super Keys Using Pair Candidate Keys – Example 08

The following diagram shows all super keys formed over the paired candidate keys, which are {A,B}, {A,C}, and {B,C}.

Finding Super Keys Using Pair Candidate Keys - Example 08

Single to Triple Candidate Keys Conversions 

Triple candidate keys are formed as: {A, B, C} over single candidate keys {A}, {B}, and {C}. The following diagram shows it

Single to Triple Candidate Keys Conversions - Example 08

Finding Super Keys Using Triple Candidate Keys

The following diagram shows all super keys formed over the triple candidate keys, which is {A,B,C}. it is called triple because it involves three candidate keys, i.e., {A}, {B}, and {C}.

Finding Super Keys Using Triple Candidate Keys - Example 08

Finding Super in DBMS Key Example 9:

To calculate the super keys of example 9, the following data is given

  • A relation R(A, B, C, D, E) represents a table with five attributes. Therefore, n=5.
  •  There are four candidate keys {A}, {B}, {C}, {D}, each of length 1.

Using the diagram below, calculate all super keys from the given data.

Finding Super Keys in DBMS Example - 09

Let’s explain the above example 9 in the following steps

Step 01: Understanding the Formula

The formula is divided into four different parts based on the number of candidate keys combined.

Super Keys Formula Understanding Example - 09.

In the above diagram

Part 1: Count super keys formed from single candidate keys

  • + 2n-1 + 2n-1 + 2n-1 + 2n-1

Part 2: Subtract super keys formed from pair candidate-key overlaps

  • − 2n-2 − 2n-2 − 2n-2 − 2n-2 − 2n-2 − 2n-2

Part 3: Add super keys formed from triple candidate-key overlaps

  • + 2n-3 + 2n-3 + 2n-3 + 2n-3

Part 4: Subtract super keys formed from quadruple candidate-key overlap

  • − 2n-4

Step 02: Single Candidate Keys to Super Keys 

The single candidate keys are {A}, {B}, {C}, and {D}. The number of super keys over single candidate keys are given in the following diagram

Finding Super Keys Using Single Candidate Keys - Example 09

Step 03: Single to Pair Candidate Keys Conversions Process 

Single to Pair Candidate Keys Conversions - Example 09

Super Keys Using Pair Candidate Keys – Example 09

Super Keys Using Pair Candidate Keys - Example 09

Single to Triple Candidate Keys Conversions – Example 09

Single to Triple Candidate Keys Conversions - Example 09

Finding Super Keys Using Triple Candidate Keys in Example 09

Finding Super Keys Using Triple Candidate Keys - Example 09

Single to Quadruple Candidate Keys Conversions in Example 09

Single to Quadruples Candidate Keys Conversions - Example 09

Finding Super Keys Using Quadruple Candidate Keys in Example 09

Finding Super Keys Using Quadruples Candidate Keys - Example 09

Finding Super Key Example 10:

To calculate the super keys of example 10, the following data is given

  • A relation R(A, B, C, D, E) represents a table with five attributes. Therefore, n=5.
  •  There are five candidate keys {A}, {B}, {C}, {D}, {E} each of length 1.

Using the diagram below, calculate all super keys from the given data.

Finding Super Keys in DBMS Example - 10

Let’s explain the above example 10 in the following steps

Step 01: Understanding the Formula

The formula is divided into five different parts based on the number of candidate keys combined.

Super Keys Formula Understanding Example - 10

Step 02: Single Candidate Keys to Super Keys 

The single candidate keys are {A}, {B}, {C}, {D} and {E}. The number of super keys over single candidate keys is given in the following diagram

Finding Super Keys Using Single Candidate Keys - Example 10

Super Keys Using Pair Candidate Keys – Example 10

Finding Super Keys Using Pair Candidate Keys - Example 10

Finding Super Keys Using Triple Candidate Keys in Example 10

Finding Super Keys Using Triple Candidate Keys - Example 10

Finding Super Keys Using Quadruples Candidate Keys in Example 10

Finding Super Keys Using Quadruples Candidate Keys - Example 10

Finding Super Keys Using Quintuples Candidate Keys in Example 10

Finding Super Keys Using Quintuples Candidate Keys - Example 10

Finding Super Key Example 11:

Category – 3:  Finding Super Key in DBMS Using Multiple Candidate Keys, having various lengths

When a relation has multiple candidate keys of same or different sizes, each candidate key can still generate many super keys. However, since some super keys may be common in more than one candidate key group, duplicate counting can happen.

To remove this problem, we use the Inclusion–Exclusion Principle, which helps us count each super key only once by adding and subtracting overlapping cases.

Finding Super Key Example 12:

To calculate the super keys of example 12, the following data is given

  • A relation R(A, B, C) represents a table with three attributes. Therefore, n=3.
  •  There are two candidate keys: {A} and {B, C}, where the length of {A} is 1 and length of {B,C} is 2

Using the diagram below, calculate all super keys from the given data.

Super Key in DBMS Example - 12

Let’s explain the above example 12 in the following steps

Step 01: Understanding the Formula 

The formula is divided into two different parts based on the number of candidate keys combined.

Super Keys Formula Understanding Example - 12

Step 02: Single Candidate Keys to Super Keys 

The single candidate keys are {A} and {B, C}. The number of super keys over single candidate keys is given in the following diagram

Finding Super Keys Using Single Candidate Keys - Example 12

Step 03: Single to Pair Candidate Keys Conversions Process 

Single to Pair Candidate Keys Conversions - Example 12

Super Keys Using Pair Candidate Keys – Example 12

Finding Super Keys Using Pair Candidate Keys - Example 12

Finding Super Key in DBMS Example 13

To calculate the super keys of example 13, the following data is given

  • A relation R(A, B, C, D) represents a table with four attributes. Therefore, n=4.
  •  There are two candidate keys: {A} and {B, C}, where the length of {A} is 1 and length of {B,C} is 2

Using the diagram below, calculate all super keys from the given data.

Super Key in DBMS Example - 13

Let’s explain the above example 13 in the following steps

Step 01: Understanding the Formula

The formula is divided into two different parts based on the number of candidate keys combined.

Super Keys Formula Understanding Example - 13

Step 02: Single Candidate Keys to Super Keys 

The single candidate keys are {A} and {B, C}. The number of super keys over single candidate keys is given in the following diagram

Finding Super Keys Using Single Candidate Keys - Example 13

Step 03: Single to Pair Candidate Keys Conversions Process 

Single to Pair Candidate Keys Conversions - Example 13

Super Keys Using Pair Candidate Keys – Example 13

Finding Super Keys Using Pair Candidate Keys - Example 13

Finding Super Key Example 14:

To calculate the super keys of example 14, the following data is given

  • A relation R(A, B, C, D) represents a table with four attributes. Therefore, n=4.
  • There are three candidate keys: {A}, {B, C}, and {C, D}. The candidate key {A} contains one attribute (length 1), while the candidate keys {B, C} and {C, D} each contain two attributes (length 2).

Using the diagram below, calculate all super keys from the given data.

Super Key in DBMS Example - 14

Let’s explain the above example 14 in the following steps

Step 01: Understanding the Formula

The formula is divided into three different parts based on the number of candidate keys combined.

Super Keys Formula Understanding Example - 14

Step 02: Single Candidate Keys to Super Keys 

The single candidate keys are {A}, {B, C}, and {C, D}. The number of super keys over single candidate keys is given in the following diagram

Finding Super Keys Using Single Candidate Keys - Example 14

Step 03: Single to Pair Candidate Keys Conversions Process 

Single to Pair Candidate Keys Conversions - Example 14

Super Keys Using Pair Candidate Keys – Example 14

Finding Super Keys Using Pair Candidate Keys - Example 14

Single to Triple Candidate Keys Conversions – Example 14

Single to Triple Candidate Keys Conversions - Example 14

Finding Super Keys Using Triple Candidate Keys in Example 14

Finding Super Keys Using Triple Candidate Keys - Example 14

Finding Super Key Example 15:

To calculate the super keys of example 15, the following data is given

  • A relation R(A, B, C, D) represents a table with four attributes. Therefore, n=4.
  • There are three candidate keys: {A}, {B}, and {C, D}. The candidate keys {A} and {B} contain one attribute (length 1), while the candidate key {C, D} contains two attributes (length 2).

Using the diagram below, calculate all super keys from the given data.

Super Key in DBMS Example - 15

Let’s explain the above example 15 in the following steps

Step 01: Understanding the Formula 

The formula is divided into three different parts based on the number of candidate keys combined.

Super Keys Formula Understanding Example - 15

Step 02: Single Candidate Keys to Super Keys 

The single candidate keys are {A}, {B}, and {C, D}. The number of super keys over single candidate keys is given in the following diagram

Finding Super Keys Using Single Candidate Keys - Example 15

Step 03: Single to Pair Candidate Keys Conversions Process 

Single to Pair Candidate Keys Conversions - Example 15

Super Keys Using Pair Candidate Keys – Example 15

Finding Super Keys Using Pair Candidate Keys - Example 15

Single to Triple Candidate Keys Conversions – Example 15

Single to Triple Candidate Keys Conversions - Example 15

Finding Super Keys Using Triple Candidate Keys in Example 15

Finding Super Keys Using Triple Candidate Keys - Example 15

Finding Super Key Example 16:

To calculate the super keys of example 16, the following data is given

  • A relation R(A, B, C, D) represents a table with four attributes. Therefore, n=4.
  • There are three candidate keys: {A,B}, {B, C}, and {C, D}. Each candidate key contains two attributes (length k= 2).

Using the diagram below, calculate all super keys from the given data.

Super Key in DBMS Example - 16

Let’s explain the above example 16 in the following steps

Step 01: Understanding the Formula

The formula is divided into three different parts based on the number of candidate keys combined.

Super Keys Formula Understanding Example - 16

Step 02: Single Candidate Keys to Super Keys 

The single candidate keys are {A}, {B, C}, and {C, D}. The number of super keys over single candidate keys is given in the following diagram

Finding Super Keys Using Single Candidate Keys - Example 16

Step 03: Single to Pair Candidate Keys Conversions Process 

Single to Pair Candidate Keys Conversions - Example 16

Super Keys Using Pair Candidate Keys – Example 16

Finding Super Keys Using Pair Candidate Keys - Example 16

Single to Triple Candidate Keys Conversions – Example 16

Single to Triple Candidate Keys Conversions - Example 16

Finding Super Keys Using Triple Candidate Keys in Example 16

Finding Super Keys Using Triple Candidate Keys - Example 16

Finding Super Key Example 17:

To calculate the super keys of example 17, the following data is given

  • A relation R(A, B, C, D) represents a table with four attributes. Therefore, n=4.
  • There are three candidate keys: {A, B, C, D}, {B, C, D}, and {A, D}. The candidate key {A, B, C, D} contains four attributes (length 4), the candidate key {B, C, D} contains three attributes (length 3), and the candidate key {A, D} contains two attributes (length 2).

Using the diagram below, calculate all super keys from the given data.

Super Key in DBMS Example - 17\

Let’s explain the above example 17 in the following steps

Step 01: Understanding the Formula

The formula is divided into three different parts based on the number of candidate keys combined.

Super Keys Formula Understanding Example - 17

Step 02: Single Candidate Keys to Super Keys

The single candidate keys are {A, B, C}, {B, C, D}, and {A, D}. The number of super keys over single candidate keys is given in the following diagram

Finding Super Keys Using Single Candidate Keys - Example 17

Step 03: Single to Pair Candidate Keys Conversions Process 

Single to Pair Candidate Keys Conversions - Example 17

Super Keys Using Pair Candidate Keys – Example 17

Finding Super Keys Using Pair Candidate Keys - Example 17

Single to Triple Candidate Keys Conversions – Example 17

Single to Triple Candidate Keys Conversions - Example 17

Finding Super Keys Using Triple Candidate Keys in Example 17

Finding Super Keys Using Triple Candidate Keys - Example 17

Finding Super Key Example 18:

 

Step 01: Understanding the Formula

Step 02: Single Candidate Keys to Super Keys

Step 03: Single to Pair Candidate Keys Conversions Process

Super Keys Using Pair Candidate Keys – Example 18

Single to Triple Candidate Keys Conversions – Example 18

Finding Super Keys Using Triple Candidate Keys in Example 18

Single to Quadruples Candidate Keys Conversions – Example 18

Finding Super Keys Using Quadruples Candidate Keys in Example 18

Single to Quintuples Candidate Keys Conversions – Example 18

Finding Super Keys Using Quintuples Candidate Keys in Example 18

Single to Sextuples Candidate Keys Conversions – Example 18

Finding Super Keys Using Sextuples Candidate Keys in Example 18

Single to Septuples Candidate Keys Conversions – Example 18

Finding Super Keys Using Septuples Candidate Keys in Example 18

Single to Octuples Candidate Keys Conversions – Example 18

Finding Super Keys Using Octuples Candidate Keys in Example 18

 

Super Key Vs. Candidate Key in DBMS

It’s crucial to differentiate between a Super Key and a Candidate Key:

  • Super Key: A super key is any set of attributes that can uniquely identify a row in the table. It can include extra attributes that aren’t necessary for uniqueness.

  • Candidate Key: A candidate key is a minimal super key. This means it’s a super key that contains the least number of attributes necessary to uniquely identify a record. A candidate key does not contain any extraneous attributes.

Every candidate key is a super key, but not every super key is a candidate key. A candidate key is simply a minimal super key, whereas other super keys may contain redundant attributes.

Importance of Super Key in DBMS

A Super Key is an attribute or a combination of attributes that uniquely identifies each tuple (row) in a relation. Super keys play a fundamental role in database design and management for the following reasons:

  • Ensures Uniqueness: A super key guarantees that no two rows in a table have the same values for the attributes included in the super key, ensuring each record can be uniquely identified.
  • Maintains Data Integrity: By uniquely identifying records, super keys help prevent duplicate data and maintain the accuracy and consistency of the database.
  • Foundation for Candidate and Primary Keys: Every candidate key and primary key is derived from a super key. Candidate keys are minimal super keys, and one candidate key is selected as the primary key.
  • Supports Database Normalization: Super keys are important during the normalization process, helping identify functional dependencies and reduce data redundancy for a well-structured database design.
  • Improves Data Retrieval: Super keys can be used for indexing and searching, enabling the database management system to locate and retrieve records more efficiently.
  • Establishes Relationships Between Tables: Primary keys, which are selected from super keys, are referenced by foreign keys in related tables, helping maintain relationships among tables.
  • Ensures Referential Integrity: Since foreign keys reference primary keys, and primary keys originate from super keys, super keys indirectly help maintain referential integrity and consistency across the database.
  • Supports Efficient Database Design: Identifying super keys helps database designers determine the most appropriate keys for uniquely identifying records and organizing data effectively.
  • Acts as a Superset of Candidate Keys: Every super key contains a candidate key as a subset. Therefore, any attribute combination that includes a candidate key is also a valid super key.
  • Provides Flexibility in Identification: Multiple super keys may exist for a relation, giving database designers flexibility in choosing the most suitable candidate key and primary key.