- Key is used to uniquely identify any record present in the table.
- A DBMS Key can be an attribute or a set of attributes which helps to identify a record of a table.
For Example :
- Types of key:
- Primary key
- Candidate key
- Super Key
- Foreign key
- Alternate key
1) Primary key :
- Primary key is used to identify one instance of an entity uniquely.
- Table can have multiple keys, the key which is most suitable from those lists become a primary key.
- Selection of primary key in table is completly based on requirement and developers.
For example :
2) Candidate key :
- It is an attribute or set of an attribute that can uniquely identify a tuple.
- The candidate key can having only one attribute or composite as well.
For example :
3) Super Key :
- It is a set of an attribute that can uniquely identify a tuple.
- In Super key there is no restriction on number of attributes, it may consist of any number of attributes
For example :
4) Foreign key :
- To point to the primary key of another table foreign key columns are used.
- Foreign Key is used to establish relationships between two tables
5) Alternate key :
Those candidate keys which are not the Primary key are Alternate
keys.