Dbms
Dbms
Dbms
By: Kachhawah Nikhil Surendra
01 Candidate Key
1. Candidate key
The candidate keys in a table are defined as the set of keys that is minimal and can
uniquely identify any data row in the table.
• It must be unique
• It can not be null
For example:
For example:
For example:
All these can be super key for above table:
• Student_Number
• Student_Phone
• Student_Number, Student_Name
• Student_Number, Student_Phone
• Student_Number, Subject_Number
• Student_Phone, Student_Name
• Student_Phone, Subject_Number
• Student_Number, Student_Name, Student_Phone
• Student_Number, Student_Phone, Subject_Number
• Student_Number, Student_Name, Subject_Number
• Student_Phone, Student_Name, Subject_Number
04 Alternate Key
4. Alternate key
• Only one of the candidate keys is selected as the primary key. The rest of them
are known as alternate keys.
• It is also known as secondary key.
For example:
For example:
PK FK
Here DepNo in first table is used as foreign key in another to establish relation
06 Composite Key
4. Composite key
If any single attribute of a table is not capable of being the key i.e it cannot identify a
row uniquely, then we combine two or more attributes to form a key. This is known
as a composite key.
For example:
07 Unique Key
4. Unique key
• A unique key refers to a column/a set of columns that identify every record
uniquely in a table. All the values in this key would have to be unique.
• Remember that a unique key is different from a primary key. It is because it is
only capable of having one null value.
For example: