Database Keys: J M Githeko September 2019
Database Keys: J M Githeko September 2019
J M Githeko
September 2019
Introduction
• Keys are very important part of Relational database model.
• Keys are used to establish and identify relationships between tables
• Keys uniquely identify any record or row of data inside a table.
• A Key can be a single attribute or a group of attributes, where the
combination may act as a key.
Types of database keys
• Super Key
• Primary Key
• Candidate Key
• Alternate Key
• Foreign Key
• Compound Key
• Composite Key
• Surrogate Key
Example Table 1
student_id name phone age email
• The candidate keys which are not selected as primary key are known
as secondary keys or alternative keys.
Non-key Attributes
A→BCDE
• This means the attribute 'A' uniquely determines the other attributes B,C,D,E.
BC→ADE
• This means the attributes 'BC' jointly determines all the other attributes A,D,E in the
relation.
• Primary Key :A
• Candidate Keys :A, BC
• Super Keys : A, BC, ABC, AD
ABC,AD are not Candidate Keys since both are not minimal super keys.