Chapter 5 Database Key
Chapter 5 Database Key
Database Concept
Database Keys
Agenda
Database Keys
Primary key
Candidate key
Super key
Foreign key
Alternate key
Composite key
Artificial key
Keys
• Keys play an important role in the relational database.
• It is used to uniquely identify any record or row of data from the table.
• It is also used to establish and identify relationships between tables.
• For example, ID is used as a key in the Student table because it is
unique for each student.
Types of keys
1. Primary key
• It is the first key used to identify only one instance of an entity uniquely.
• The key which is most suitable from the lists becomes a primary key.
• In the EMPLOYEE table, ID can be the primary key since it is unique for
each employee.
• Except for the primary key, the remaining attributes are considered a
candidate key. The candidate keys are as strong as the primary key.
• For example: In the EMPLOYEE table, id is best suited for the primary
key. The rest of the attributes, like Passport_Number, License_Number,
etc., are considered a candidate key.
Candidate Key
3. Super key
• Super key is an attribute set that can uniquely identify a tuple. A super
key is a superset of a candidate key.
• The key created using arbitrarily 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 values of the
artificial keys are usually numbered in a serial order.