Menu

SQL Keys Explained: Fast Revision Notes for IBPS SO IT Officer 2026

MockSensei Team
July 10, 2026
11 min read
DBMS & SQL
SQL Keys Explained: Fast Revision Notes for IBPS SO IT Officer 2026

SQL Keys are among the most important topics in DBMS and are frequently asked in IBPS SO IT Officer, NIELIT, GATE, UGC NET, and technical interviews. Instead of memorizing definitions, understanding how different keys are related makes it much easier to answer conceptual questions.

This Fast Revision Guide focuses on the most important concepts, high-weightage comparisons, and common exam traps so you can revise the topic in just a few minutes.

Focus on the hierarchy, comparison tables, and exam traps. They cover the majority of SQL Key questions asked in competitive exams.

Quick Revision Cheat Sheet

KeyUniqueNULL AllowedPurpose
Super Key✅ YesDependsIdentify records uniquely
Candidate Key✅ Yes❌ NoMinimal unique identifier
Primary Key✅ Yes❌ NoMain identifier
Alternate Key✅ YesUsually NoCandidate Key not selected
Foreign Key❌ No✅ YesMaintain relationships
Composite Key✅ Yes❌ NoIdentify records using multiple columns

Exam Trap: Every Candidate Key is a Super Key, but every Super Key is not a Candidate Key.

Hierarchy of SQL Keys

Hierarchy of SQL Keys
Relationship between Super Key, Candidate Key, Primary Key, Alternate Key, Foreign Key, and Composite Key.

Understanding this hierarchy is more important than memorizing individual definitions.

Super Key
    │
    ├── Candidate Key
    │        │
    │        ├── Primary Key
    │        └── Alternate Key
    │
    ├── Foreign Key
    │
    └── Composite Key

Why Are SQL Keys Important?

Imagine an online banking system where:

  • Two customers have the same Account Number.
  • Transactions refer to accounts that do not exist.
  • Customer records cannot be uniquely identified.

Such a database would become inconsistent and unreliable.

SQL Keys solve these problems by:

  • Uniquely identifying records.
  • Eliminating ambiguity.
  • Maintaining relationships between tables.
  • Enforcing data integrity.
  • Improving database performance and consistency.

1. Super Key

A Super Key is a column or a combination of columns that can uniquely identify every row in a table.

A Super Key may contain extra attributes that are not required for uniqueness.

Example

Consider the following table:

StudentIDEmailAadhaarName
101rahul@gmail.com1234Rahul
102priya@gmail.com5678Priya

Possible Super Keys include:

  • StudentID
  • Email
  • Aadhaar
  • StudentID + Name
  • Email + Name
  • StudentID + Email

Notice that StudentID + Name is still unique, even though Name is unnecessary.

Important Points

  • Every Candidate Key is a Super Key.
  • A Super Key may contain extra columns.
  • There can be many Super Keys in a table.
  • The smallest Super Keys become Candidate Keys.

A Super Key guarantees uniqueness, but it is not necessarily the most efficient choice because it may include unnecessary attributes.

2. Candidate Key

A Candidate Key is the smallest possible Super Key that uniquely identifies each row.

Unlike a Super Key, it contains no unnecessary attributes.

Example

Suppose the following attributes are unique:

  • StudentID
  • Email
  • Aadhaar

Then all three are Candidate Keys because each one alone uniquely identifies a student.

However:

StudentID + Name

is not a Candidate Key because Name is unnecessary.

Important Points

  • Every Candidate Key is unique.
  • A table can have multiple Candidate Keys.
  • Candidate Keys contain the minimum number of attributes required for uniqueness.
  • One Candidate Key is later selected as the Primary Key.

Super Key vs Candidate Key

FeatureSuper KeyCandidate Key
Unique
Extra AttributesMay containNo
Minimal
Number per TableManyOne or More

Memory Trick: Think of a Candidate Key as the "best" Super Key because it achieves uniqueness without carrying unnecessary columns.

3. Primary Key

A Primary Key is the Candidate Key chosen to uniquely identify every row in a table.

Every table can have only one Primary Key, although that Primary Key may consist of multiple columns (Composite Primary Key).

Syntax

CREATE TABLE Student (
    StudentID INT PRIMARY KEY,
    Name VARCHAR(50),
    Email VARCHAR(100)
);

Example

StudentIDNameEmail
101Rahulrahul@gmail.com
102Priyapriya@gmail.com
103Amitamit@gmail.com

The StudentID uniquely identifies every record.

Characteristics of a Primary Key

  • Must contain unique values.
  • Cannot contain NULL values.
  • Only one Primary Key constraint is allowed per table.
  • Automatically enforces UNIQUE and NOT NULL.
  • Used to establish relationships with other tables.

Candidate Key vs Primary Key

Candidate KeyPrimary Key
One or more may existOnly one per table
All are eligible to become Primary KeySelected from Candidate Keys
Not all Candidate Keys are chosenUsed as the main identifier

Exam Tip

Many students think:

Every unique column automatically becomes the Primary Key.

This is incorrect.

A Primary Key is selected from the available Candidate Keys.

Other Candidate Keys become Alternate Keys, which we'll discuss next.

Exam Trap: A table may have many Candidate Keys but only one Primary Key.

Quick Summary

KeyPurposeUniqueNULL
Super KeyIdentify rowsDepends
Candidate KeyMinimal unique identifier
Primary KeyMain identifier
Recommended

Revise SQL Constraints

SQL Constraints and SQL Keys are closely related. Strengthen your concepts before moving to SQL Joins.

Read SQL ConstraintsFree • No signup required

4. Alternate Key

An Alternate Key is a Candidate Key that was not selected as the Primary Key.

In simple words:

Primary Key = Selected Candidate Key
Alternate Key = Remaining Candidate Keys

Example

Consider the following table:

StudentIDEmailAadhaarName
101rahul@gmail.com123456789012Rahul
102priya@gmail.com987654321098Priya

Here:

  • StudentID → Candidate Key ✅ (Selected as Primary Key)
  • Email → Candidate Key ✅ (Alternate Key)
  • Aadhaar → Candidate Key ✅ (Alternate Key)

Important Points

  • Alternate Keys are unique.
  • Multiple Alternate Keys can exist.
  • They are Candidate Keys that were not chosen as the Primary Key.

Remember: Every Alternate Key is a Candidate Key, but not every Candidate Key is an Alternate Key.

5. Foreign Key

A Foreign Key is a column (or group of columns) that creates a relationship between two tables.

It references the Primary Key (or another UNIQUE key) of another table and helps maintain Referential Integrity.

Example

Department Table (Parent)

DepartmentIDDepartmentName
10Computer Science
20Information Technology

Student Table (Child)

StudentIDNameDepartmentID
101Rahul10
102Priya20

The value of DepartmentID in the Student table must already exist in the Department table.

Syntax

CREATE TABLE Department(
    DepartmentID INT PRIMARY KEY,
    DepartmentName VARCHAR(50)
);

CREATE TABLE Student(
    StudentID INT PRIMARY KEY,
    Name VARCHAR(50),
    DepartmentID INT,
    FOREIGN KEY (DepartmentID)
        REFERENCES Department(DepartmentID)
);

Important Points

  • Maintains relationships between tables.
  • Prevents invalid references.
  • Duplicate values are allowed.
  • NULL values are generally allowed unless restricted separately.
  • Multiple Foreign Keys can exist in a table.

Remember: A PRIMARY KEY enforces Entity Integrity, while a FOREIGN KEY enforces Referential Integrity.

6. Composite Key

A Composite Key is a key formed by combining two or more columns to uniquely identify a record.

It is useful when a single column cannot uniquely identify each row.

Example

CREATE TABLE Enrollment(
    StudentID INT,
    CourseID INT,
    PRIMARY KEY(StudentID, CourseID)
);

Neither StudentID nor CourseID is unique individually.

However,

(StudentID, CourseID)

uniquely identifies each enrollment record.

Important Points

  • Combines multiple columns.
  • Used when one column is insufficient.
  • A Composite Primary Key is still one Primary Key constraint.

Exam Trap: A Composite Primary Key does not mean multiple Primary Keys. A table can have only one PRIMARY KEY constraint.

High-Weightage Comparison Tables

Super Key vs Candidate Key

FeatureSuper KeyCandidate Key
Uniquely identifies rows
Contains extra attributesMay containNo
Minimal
Number per tableManyOne or More

Candidate Key vs Primary Key

Candidate KeyPrimary Key
Many can existOnly one per table
Eligible to become Primary KeySelected Candidate Key
All Candidate Keys are uniqueAlways unique

Primary Key vs Foreign Key

Primary KeyForeign Key
Identifies recordsCreates relationships
UniqueMay contain duplicates
Cannot contain NULLCan contain NULL
One per tableMultiple allowed
Entity IntegrityReferential Integrity

Primary Key vs Alternate Key

Primary KeyAlternate Key
Chosen Candidate KeyRemaining Candidate Keys
One per tableMultiple allowed
Main identifierSecondary unique identifiers

SQL Keys Hierarchy (Quick Revision)

Super Key
      │
      ├── Candidate Key
      │         │
      │         ├── Primary Key
      │         └── Alternate Key
      │
      ├── Foreign Key
      │
      └── Composite Key

Memory Tricks

Hierarchy

Super

↓

Candidate

↓

Primary

↓

Alternate

Think of it as a filtering process:

  • Every Primary Key is a Candidate Key.
  • Every Candidate Key is a Super Key.

Foreign Key

Foreign Key

↓

Relationship

↓

Referential Integrity

Common Exam Traps

These conceptual questions are frequently asked in competitive exams.

Trap 1

Can a table have multiple Candidate Keys?

Yes

Trap 2

Can a table have multiple Primary Keys?

No

Trap 3

Can a Primary Key be Composite?

Yes

Trap 4

Can a Foreign Key contain duplicate values?

Yes

Trap 5

Can a Foreign Key contain NULL values?

Yes, unless restricted by a NOT NULL constraint.

Trap 6

Is every Candidate Key a Super Key?

Yes

Trap 7

Is every Super Key a Candidate Key?

No

Trap 8

Can a Foreign Key reference a UNIQUE key?

Yes

A Foreign Key can reference a PRIMARY KEY or another column (or set of columns) with a UNIQUE constraint, provided it uniquely identifies rows.

Trap 9

Can a Composite Key consist of three columns?

Yes

A Composite Key can contain two or more columns.

Trap 10

Can a table exist without a Primary Key?

Yes

Although a Primary Key is strongly recommended, SQL does not require every table to have one.

One-Page Revision Sheet

KeyUniqueNULL AllowedMain Purpose
Super KeyDependsUniquely identify records
Candidate KeyMinimal unique identifier
Primary KeyMain identifier
Alternate KeyDependsCandidate Key not selected
Foreign KeyMaintain relationships
Composite KeyMulti-column identifier

🎯 Revision Checklist

Tick the concepts you're confident about before attempting the mock test.

0/8
Revision Progress0%
Keep revising.

What to Study Next

Strengthen your DBMS concepts with these related articles.

TopicStatus
SQL Commands✅ Available
SQL Constraints✅ Available
SQL Joins🚧 Coming Soon
Normalization🚧 Coming Soon
ACID Properties🚧 Coming Soon
Transactions🚧 Coming Soon
Free Practice

Ready to Test Your SQL Keys Knowledge?

Attempt a topic-wise SQL Keys mock test with exam-level questions, detailed explanations, and performance analysis.

Start SQL Keys Mock TestFree • No signup required

Frequently Asked Questions (FAQs)

SQL Keys are attributes or sets of attributes that uniquely identify records and establish relationships between database tables.