BCA / B.Tech 11 min read

Keys in DBMS and Their Types

Keys & Their Types in DBMS:

Keys are a crucial part of a relational database. They are attributes or a set of attributes that help you to uniquely identify a row (tuple) in a table and establish relationships between tables.

Types of Keys:
  • Super Key: A set of one or more attributes that can uniquely identify a record in a table.
  • Candidate Key: A minimal super key, meaning it's a super key with no redundant attributes. A table can have multiple candidate keys.
  • Primary Key: A candidate key chosen by the database designer to uniquely identify records in a table. It cannot have NULL values. Each table can have only one primary key.
  • Foreign Key: An attribute in one table that refers to the primary key of another table. It is used to link two tables.
  • Alternate Key: The candidate keys that are not chosen as the primary key.
  • Composite Key: A primary key that consists of two or more attributes that together uniquely identify a record.
  • Surrogate Key: An artificial key created by the system (often an auto-incrementing integer) to act as a primary key, especially when no natural candidate key exists.