Types of Keys in SQL Server
Types of Keys in SQL Server
1. Super Key Super key is a set of one or more than one key which is used to identify a record uniquely in a table.
2. Primary Key Primary key is a set of one or more columns of a table that is used to uniquely identify a record in a table.
3. Unique Key Unique key is a set of one or more columns of a table that are used to uniquely identify a record in a table. It can accept only one null value and it cannot have duplicate values in it.
4. Alternate Key Alternate key is a key that can be work as a primary key if required. We can say that alternate key acts as a candidate for primary key.
5. Candidate Key Candidate Key is a set of one or more columns that are used to identify a record uniquely in a table like a primary key or we can also say that other fields than primary key which can become primary key is known as candidate key. A table can have more than one candidate key.
6. Composite Key Composite Key is a combination of more than one columns of a table to uniquely identify the record. Fields which we combine to make composite key are candidate and primary key.
7. Foreign Key Foreign Key is a column in one table that is primary key in another table. It can also accept multiple null values and duplicate values as well.
