• important role in RDBMS
  • It is used to uniquely identify any record data from the table.
  • establish and identify relationships between tables.
  • attribute or set of attributes which helps you to identify a row(tuple) in a relation(table).
  • They allow you to find the relation between two tables
  • e. g ID is used as a key in the Student table because it is unique for each student
  1. Primary Key (PK):

    • unique identifier for a record/instance in a table.
    • first key used to identify one and only one instance of an entity uniquely
    • It must contain unique values, and it cannot have NULL values.
    • Each table can have multiple keys but only one most suitable from those becomes primary key.
    • selection is based upon the developers requirement
    • E. g Employee ID for employee, Roll NO. for student
  2. Foreign Key (FK):

    • A foreign key is a field in a table that refers to the primary key in another table.
    • It establishes a link between the two tables, enforcing referential integrity.
    • The foreign key ensures that the values in the referencing column correspond to the values in the referenced primary key column.
    • prevent actions that would destroy links between tables
  3. Candidate Key:

  • A candidate key is a column or a set of columns that can qualify as a primary key.
  • The Primary key should be selected from the candidate keys.
  • Except for the primary key, the remaining attributes are considered a candidate key.
  • Like a primary key, it must be unique and not contain NULL values.
  • In a table, there can be multiple candidate keys, and the database designer chooses one of them to be the primary key.
  1. Super Key:

    • A super key is a set of one or more columns that uniquely identifies each row in a table.
    • It can contain more columns than necessary to uniquely identify a row.
    • A super key may include candidate keys or other extra columns.
  2. Alternate Key:

    • one or more attributes or a combination of attributes that uniquely identify each tuple in a relation.
    • These attributes or combinations of the attributes are called the candidate keys.
    • One key is chosen as the primary key from these candidate keys, and the remaining candidate key, if it exists, is termed the alternate key.
  3. Artificial Key:

    • A simple key is a single column that acts as a key by itself, such as a basic attribute.
    • The key created using randomly assigned data are known as artificial keys.
    • These keys are created when a primary key is large and complex and has no relationship with many other relations.
    • The data usually numbered in a serial order.
    • For example, the primary key, which is composed of Emp_ID, Emp_role, and Proj_ID, is large in employee relations.
    • So it would be better to add a new virtual attribute to identify each tuple in the relation uniquely
  4. Composite Key:

    • A composite key is a key that consists of two or more columns to uniquely identify a record.
    • The combination of Attributes creates a unique identifier.
    • For example, in employee relations, we assume that an employee may be assigned multiple roles, and an employee may work on multiple projects simultaneously.
    • So the primary key will be composed of all three attributes, namely Emp_ID, Emp_role, and Proj_ID in combination.

  1. Super key

  2. A super key is a group of single or multiple keys which identifies rows in a table.

  3. Super key is an attribute set that can uniquely identify a tuple.

  4. A super key is a superset of a candidate key.