---
title: "What is the differences between Keys in SQL"  
description: "What is the differences between Keys in SQL"  
author: "Simond Gear"  
published: 2016-02-28  
updated: 2016-02-28  
canonical: https://www.mindstick.com/forum/34013/what-is-the-differences-between-keys-in-sql  
category: "database"  
tags: ["database", "keys", "database design"]  
reading_time: 2 minutes  

---

# What is the differences between Keys in SQL

Hi,\
Please give me a exact [difference](https://www.mindstick.com/articles/157114/good-news-or-bad-news-and-the-difference-is) between among different types of [keys in sql](https://www.mindstick.com/interview/34482/keys-in-sql-server-complete-guide) such as [Primary Key](https://www.mindstick.com/blog/214/primary-key),Foriegn Key etc.Thank you.

## Replies

### Reply by Anupam Mishra

Hi Simond,Their is basically following [keys](https://www.mindstick.com/articles/75385/full-product-keys) in [SQL](https://www.mindstick.com/articles/13115/types-of-keys-in-sql-or-oracle-database):\
**1. Candidate Key****2. [Primary](https://www.mindstick.com/forum/33739/difference-between-primary-key-and-unique-key) Key****3. Foriegn Key****4. Alternate Key****5. Composite Key**\
Here, we are explaining a simpler way to each key :\
**Candidate Key:** **\****Candidate keys** are those keys which is candidate for **primary key** of a table. In simpler we can understand that such type of keys which full fill all the requirements of primary key which is not null and have unique records is a candidate for primary key. So thus type of key is known as candidate key. **Every table must have at least one candidate key** .**\****Primary Key:****\**Such type of **candidate key** **which is chosen as a primary key** **for table is known as primary key**. **Primary keys are used to identify tables.** **There is only one primary key per table**. **\****Foreign Key:****\****Foreign key** are those keys which is used to **define relationship between two tables**. When we want to implement relationship between two tables then we use concept of foreign key. **It is also known as referential integrity**.\
**Alternate Key:****\**If any table have more than one candidate key, then after choosing primary key from those candidate key, **rest of candidate keys are known as an alternate key of that table**. \
**Composite Key:****\**When we create keys on more than one column then that key is known as composite key. I have a table **Employee** which has two columns **Empid** and **EmpReferenceNo** and we make primary key on these two column. Then **this key is known as composite key:****\****For More details with example ,Please click [HERE](https://www.mindstick.com/Articles/11986/sql-keys-in-rdbms)**


---

Original Source: https://www.mindstick.com/forum/34013/what-is-the-differences-between-keys-in-sql

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
