Super Key

A Super Key is a set of one or more columns that can uniquely identify each row in a table.

Key Points:

  • Every primary key, candidate key, and alternate key is a super key.
  • But not every super key is minimal.
  • If a super key has extra columns that are not necessary to maintain uniqueness, it is not a candidate key.
  • In other words: Candidate Key = Minimal Super Key.

Example:

CREATE TABLE Employees (
    EmployeeID INT,
    Email VARCHAR(100) NOT NULL,
    NationalID VARCHAR(20) NOT NULL,
    Name VARCHAR(100)
);

Super Keys examples:

  1. (EmployeeID)
  2. (Email)
  3. (NationalID)
  4. (EmployeeID, Email) – this is still unique, so also a super key, but not minimal
  5. (EmployeeID, Name) – still unique, also a super key, but extra column makes it non-minimal

Candidate Keys: EmployeeID, Email, NationalID (minimal super keys) Primary Key: EmployeeID Alternate Keys: Email, NationalID

Relationship Summary:

  • Super Key: Any column(s) that uniquely identifies rows (may have extra columns).
  • Candidate Key: Minimal super key (no extra columns).
  • Primary Key: Chosen candidate key.
  • Alternate Key: Candidate key not chosen as primary.
  • Unique Key: Enforces uniqueness (can be candidate/alternate).
  • Foreign Key: References primary key of another table.
  • Composite Key: Primary key made of multiple columns.

<div class=’mermaid> flowchart TD %% Super Key Level %% A[Super Key
Any column(s) that uniquely identifies rows] –> B[Candidate Key
Minimal super key(s)]

%% Candidate Key splits %%
B --> C[Primary Key<br><i>Chosen candidate key</i>]
B --> D[Alternate Key<br><i>Candidate key not chosen as primary</i>]

%% Unique Key (can overlap with Candidate/Alternate) %%
D --> E[Unique Key<br><i>Enforces uniqueness; can be alternate or other columns</i>]
C --> E

%% Foreign Key %%
F[Foreign Key<br><i>References primary key of another table</i>] 

%% Composite Key %%
G[Composite Key<br><i>Primary key with multiple columns</i>]

%% Relationships %%
C --> F
G --> C

%% Styling for dark background %%
classDef light fill:#1f1f1f,stroke:#ccc,stroke-width:1px,color:#fff;
class A,B,C,D,E,F,G light;
linkStyle default stroke:#ccc,stroke-width:2px,arrowhead:vee;

</div>