Home » Database Management System » Unit 1: Introduction » Discuss candidate key, primary key, super key, composite key, and alternate key OR Explain primary key, super key, foreign key, and candidate key with examples. OR Define key. Explain various types of keys.

Discuss candidate key, primary key, super key, composite key, and alternate key OR Explain primary key, super key, foreign key, and candidate key with examples. OR Define key. Explain various types of keys.

Support this post with a reaction:

5,761 views

 Super Key is any attribute or set of attributes that can uniquely identify a tuple in a relation. A super key may contain additional attributes that are not actually necessary for unique identification. For example, in a Student table with attributes (RollNo, Name, Email), both {RollNo} and {RollNo, Name} are super keys, since both can uniquely identify a student, even though Name is not required for uniqueness in the second one.

 Candidate Key is a minimal super key, meaning it has no unnecessary extra attributes; removing any attribute from it would cause it to lose its ability to uniquely identify tuples. A table can have more than one candidate key. For example, in the Student table, both RollNo and Email could individually act as candidate keys if each is guaranteed to be unique for every student.


 Primary Key is the candidate key chosen by the database designer to be the main means of uniquely identifying tuples in a table. Once selected, it cannot contain null values and must remain unique for every row. For example, if RollNo and Email are both candidate keys, the designer might choose RollNo as the primary key for the Student table.

 Alternate Key refers to the candidate keys that were not selected as the primary key. Using the same example, if RollNo is chosen as the primary key, then Email becomes the alternate key, since it was also capable of uniquely identifying rows but was not selected as the main key.

Composite Key (also called a compound key) is a key that consists of two or more attributes combined together to uniquely identify a tuple, used when no single attribute alone is sufficient for uniqueness. For example, in an Enrollment table recording which students take which courses, neither StudentID alone nor CourseID alone may be unique, since a student can enroll in many courses and a course can have many students, but the combination (StudentID, CourseID) together uniquely identifies each enrollment record, making it a composite key.

 Foreign Key, though not listed in the question, is closely related and worth mentioning briefly, since it is an attribute in one table that refers to the primary key of another table, used to establish and enforce relationships between two tables, such as DeptID in the Employee table referring to DeptID in the Department table.