# Keys

* Key is the attribute to search a record in the database.
* It is used to establish and identify relationships between tables.
* It identify any record or row of data uniquely.

## Types of Keys

* Super Key
* Candidate Key
* Primary Key
* Composite Key
* Foreign Key
* Secondary or Alternative key
* Non-key Attributes
* Non-prime Attributes

## Super Key

* Super Key A set of attributes within a table that can uniquely identify each record in a table.
* Super Key is a super-set of Candidate key.

## Candidate Key

* Candidate Key A set of attribute which can uniquely identify each record in a table.
* A candidate key can never be NULL or empty.
* Its value should be unique.
* There can be more than one candidate keys for a table.
* A candidate key can be a combination of more than one attribute.

## Primary Key

* Primary Key is the most appropriate candidate key that can uniquely identify each record in a table.

## Composite Key

* Composite Key is consists of two or more attributes that uniquely identify any record in a table.
* But the attributes which together form the Composite key are not a key independently or individually.

## Foreign Key

* Foreign keys are the attribute of the table which is used to point to the primary key of another table.

## Secondary or Alternative key

* &#x20;The candidate key which are not selected as primary key.

## Non-key Attributes

* Attributes or fields of a table, other than candidate key in a table.

## Non-prime Attributes

* Attributes other than Primary Key.
