DBMS Keys : Primary, Super, Candidate, Composite and Foreign key

DBMS Keys :

DBMS Keys are a data item that exclusively identifies a record.
Example: Account_number, Employee_number and customer_number are used a DBMS Keys because they specifically identify a record stored in a database.

Super Key :

A Super key for an entity is a set of one or more attributes whose combined value uniquely identifies the entity in the entity set. Superset of any candidate key is also known as Super key.
Example:

Roll_NoNameAge
700101
Ram
20
700102
Sam
19
700103
Modhu
18

Here Four Super Keys are present in this table is given below:

  • {Roll_No} DBMS Keys
  • {Roll_No, Name} DBMS Keys
  • {Roll_No, Age} DBMS Keys
  • {Roll_No, Name, Age} DBMS Keys

Primary Key :

The primary key uniquely identifies each record in a table and must never be the same for two records.
Example:

Student_RollStudent_NameStudent_Age
70101Dipak20
70102Sagar21
70103Krishna19
70104Rakhi18

Here only one Primary Key is present in this table is given below:

  • {Student_Roll} DBMS Keys

    Candidate Key :

    A candidate key is an attribute or set of attributes that uniquely identifies a record. These attributes or combinations of attributes are called candidate keys.
    Example:

    Emp_idEmp_NameEmp_Email
    S001Ram[email protected]
    S002Sam[email protected]
    S003Jodhu[email protected]

    Here Two Candidate Keys are present in this table is given below:
  • {Emp_id} DBMS Keys
  • {Emp_Email} DBMS Keys

    Composite Key :

    A composite key is a group of fields that are combined to uniquely identify a record. When we design a database, we will have tables that will use more than one column as a part of the primary key. These keys are called composite key or concatenated key.
    Example:

    Order_idProduct_idProduct_Price
    1192555555000
    11926555610000
    1192755577500

    Here Two Composite Keys are present in this table is given below:
  • {Order_id} DBMS Keys
  • {Product_id} DBMS Keys
  • Foreign Key :

    In relation, the column whose data values correspond to the values of a key column in another relation is called a Foreign Key.

    Secondary Key :

    A secondary key is an attribute or combination of attributes that may not be a candidate key but classifies the entity set on a particular characteristic.