- Super Key
A superkey is a set of one or more attributes which put together enable us to identify uniquely an entity in the entity set.
For example in entity set Employee, shown in fig. given below, Super Keys are
- (ID, Name, Salary, Reg. No.)
- (ID, Name, Reg. No.)
- (ID) etc.
All combinations can identify data uniquely.
Employee
Reg. No. |
ID | Name | Salary | Dept-ID |
SGL01 |
1 | Nancy | 10000 |
10 |
SGL02 |
2 | John | 12000 | 05 |
SGL03 | 3 | Peter | 16000 |
08 |
SGL04 |
4 | Nina | 16500 |
04 |
Department
Dept-ID |
Dept-Name |
10 |
Human Resource |
05 |
Packaging |
04 |
Marketing |
- Candidate Key
A superkey may contain extraneous attributes and we are often intrest in the smallest superkey. A superkey for which no subset is a superkey is called candidate key. For Example ID and Registration no. are candidate key.
- Primary Key
It is a candidate key that is chosen by the database designer as the principle means of identifying entities within an entity set. For example In Entity set Employee either Reg. No. is primary key or ID is primary key.
4.Foreign Key
An attribute or set of attributes, within one relation that matches the candidate key of some relation. A foreign key is an attribute in any entity set which is also a Primary Key in any other entity set. For Example Dept ID : This is an attribute in entity set. Employee and also a primary Key in entity set Department. Thus it is a foreign key in Employee.