Difference between Primary key and Super key

Last Updated : 12 Jul, 2025

Key concepts that play a significant role in DBMS are the Primary Key and the Super Key. While both are fundamental to the structure and functionality of a database, they serve distinct purposes and have different characteristics. A Primary Key is a specific, minimal set of attributes that uniquely identifies a record in a table, ensuring that each entry is unique and non-null. On the other hand, a Super Key is any combination of columns that can uniquely identify a record, but it might include extra information that isn’t necessary.

What is Super Key?

Super Key is an attribute (or set of attributes) that is used to uniquely identify all attributes in a relation. All super keys can’t be candidate keys but its reverse is true. In a relation, a number of super keys is more than a number of candidate keys.

A Super Key is any combination of columns in a database table that can uniquely identify each record. It might include extra columns beyond what’s needed, but it ensures that each row in the table is unique.

Example 1:

We have a given relation R(A, B, C, D, E, F) and we shall check for being super keys by following given functional dependencies:

Screenshot-2024-09-06-084707

By Using key AB we can identify rest of the attributes (CDEF) of the table. Similarly Key CD. But, by using key CB we can only identifies D and F not A and E. Similarly key D.

Example 2:

StudentID

Email

Name

DOB

001

khushi@gmail.com

Khushi Lad

24-05-2001

002

aryan12@gmail.com

Aryan Ross

03-09-2003

003

benny34@gmail.com

Benny Bing

29-02-2004

Super Keys in This Table:

  • {StudentID}: This is a Super Key because it uniquely identifies each student.
  • {Email}: This is also a Super Key because each email address is unique to a student.

Super and Primary keys are essential concepts in database design, ensuring data integrity and access efficiency. To solidify your understanding of keys and other DBMS topics, the GATE CS Self-Paced Course offers detailed explanations and practical examples.

What is Primary Key?

A Primary Key is a unique identifier for each record in a database table. It makes sure that every record is different from all the others, and it cannot be empty or have duplicates. Think of it like a special ID number that every row in the table must have to be easily recognized.

Candidate key is a set of attributes (or attribute) which uniquely identify the tuples in a relation or table. There can be more than one candidate key in relation out of which one can be chosen as the primary key.

Example 1:

Screenshot-2024-09-06-084811

Here we can see the two candidate keys Stud_No and Stud_phone. STUD_No can be chosen as the primary key (only one out of many candidate keys).

Example 2: Concider a table called Orders in an online shopping database. This table stores information about customer orders:

OrderID

Customer Name

Product

Quantity

1001

Amit

Headphone

2

1002

Sam

Laptop

1

1003

Roy

Watch

3

In this table:

  • OrderID is the Primary Key.
  • It uniquely identifies each order in the table. No two orders can have the same OrderID, and it cannot be left empty.
  • For example, OrderID 1001 refers to Amit's order for 2 Headphone, and OrderID 1002 refers to Sam's order for 1 Laptop . This ensures that each order is uniquely tracked by its OrderID.

Difference Between Super Key and Primary Key

Super KeyPrimary Key
Super Key is an attribute (or set of attributes) that is used to uniquely identifies all attributes in a relation.Primary Key is a minimal set of attribute (or set of attributes) that is used to uniquely identifies all attributes in a relation.
All super keys can't be primary keys.Primary key is a minimal super key.
Various super keys together makes the criteria to select the candidate keys.We can choose any of the minimal candidate key to be a primary key.
In a relation, number of super keys are more than number of primary keys.While in a relation, number of primary keys are less than number of super keys.
Super key's attributes can contain NULL values.Primary key's attributes cannot contain NULL values.

Conclusion

In conclusion, understanding the distinction between Primary Keys and Super Keys is essential for effective database design. By recognizing and applying these key concepts appropriately, database designers can create more efficient, reliable, and well-organized databases that support accurate data management and retrieval.

Comment

Explore