Answer» - Super key: Super Key is a set of attributes that can be used to uniquely identify a tuple. The super key is created by adding ZERO or more attributes to the candidate key. A candidate key is a super key, but not the other way around.
- Candidate key: A candidate key is the smallest set of attributes that can uniquely identify a tuple. For each tuple, the Candidate Key value is unique and non-null. In relation, there can be more than one candidate key. The candidate key MIGHT be simple (only having one attribute) or composite (CONTAINING multiple attributes).
- Primary key: In relation, there may be more than one candidate key, with one being chosen as the primary key. This primary key is chosen by the database administrator based on the requirements amongst the candidate keys.
- Foreign key: A foreign key is a column or set of columns in a relational database table that connects data from two other tables. It serves as a cross-reference between tables by referencing the primary key of another table and therefore creating a relationship between them.
For example, let US consider tables with the following schema : Teacher : teacher_id (primary key), teacher_name, teacher_phone_number, teacher_aadhar, teacher_department_idDepartment : department_id (primary key), department_nameHere, for the Teacher table, the following are the DIFFERENT types of keys present : - The candidate keys can be teacher_id, teacher_phone_number and teacher_aadhar since they all can uniquely identify a record of the table.
- Out of the above three candidate keys, any one of them can be chosen as the primary key. We generally choose teacher_id as the primary key.
- Any of the above candidate keys when grouped with any other key form the super key. For example, teacher_id, teacher_name can together form a super key.
- Teacher_department_id is a foreign key for the Teacher table since it is a primary key in the Department table and it links the two tables.
|