Keys :- A keys is a data item that uniquely identifies a record.For example, account number, product code, customer no, are used as key fields because they identify a records stored in a database. There are different types of keys used in database.
Super keys :- Super key for an entity is a set of one or more attributes whose combined value uniquely identifies the entity in entity set. For example: The entity set EMPLOYEE, the set of attribute can be considered to be a super key.
Primary key :- Primary key is uniquely identifies each record in the table and must never be the same for two records. For example: EMPLOYEE-code is a primary key for the entity set EMPLOYEE.
Candidate key :- Candidate key is an attribute or set of attribute that identifies a record. These attribute or combination of attribute are called candidate key. In case, one of the candidate key is chosen to be a primary key. candidate key also called Alternate keys. For example: A ROLL-NO and MOBILE-NO are two candidate key in the STUDENT table. If ROLL-NO set a primary key, the other candidate key MOBILE-NO as the alternate key.
Composite key :- A record cannot be uniquely identified by a single field in case composite key used. The composite key is a group of filed that uniquely identify a records. For example: A group of ROLL-NO and CLASS attribute from a STUDENT table is known as composite key.
Foreign key :- In the relation column whose data value correspond to the value of a key column in another relation is called a foreign key. A foreign key is a column or a combination of column whose match the primary key in a different table.