MySQL SUPER Key

MySQL | SUPER Key: Learn about the MySQL SUPER Key, with its explanation, syntax, and query examples.
Submitted by Apurva Mathur, on September 15, 2022

SUPER Key

When a group of attributes/columns distinctly identify the records those attributes are known as the super key.

The super key concept is theoretical but it is really important for competitive purposes.

Let us understand this concept through an example;

Suppose we have a table named "student_details" and inside this table, we have the following columns,

  • Student_ID
  • Student_Name
  • Roll_Number
  • DOB
  • Email
  • Address
  • Branch

Now, suppose if I only take any "Student_Name", will that be unique? No, of course, because we may have many students of the same name, now if I only consider "DOB" (date of birth) will that alone be considered as unique records? Nor this can be considered a unique record as many students have a common date of birth, but what if I take a combination of "Student_Name", "DOB", and "Roll_Number", now the records which will come inside these attributes will be unique? Obviously because now the roll number column is added and with the help of this we can easily get the distinct record.

A table may have single or pair of attributes as the super key.

According to the above table we can have the following super keys,

  • Student_ID: The student's IDs attribute is unique itself so it is also considered a super key.
  • Roll_Number: The roll numbers of every student are unique so this will be also considered a super key.
  • Email: Emails are always unique; in this entire world no one can have the same emails.
  • Student_ID + Student_Name: This combination will always give unique records.
  • Student_ID + Student_Name + Roll_Number: This combination will be also unique so the set of these attributes will be considered a super key.

We can make many super keys in one table, the only condition it should follow is that, it should be unique, doesn't matter if it is a single attribute or group of attributes, but it should give distinct records.




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.