Types of KEY in MySQL
KEY NAMES | KEY DESCRIPTION |
---|---|
PRIMARY KEY | Name of the column which uniquely identifies each row of the table with no null value in any row of the table. |
UNIQUE KEY | Name of the column which uniquely identifies each row of the table, but it can accept a null value for any row of the table. |
COMPOSITE KEY | The combination of two or more column representing as a unique for each row of the table after merging the columns. It acts like a single column in contest of the key. |
SURROGATE KEY | A key which has no buisness logic or which have no existance in the real world. for more clarity see NATURAL KEY |
FOREIGN KEY | Name of the column which have the reference of the other table by having the same value of any column other table. |
CANDIDATE KEY | Any key which can represent as unique for each row is called CANDIDATE KEY. Hence PRIMARY KEY, UNIQUE KEY and COMPOSITE KEY are a member of CANDIDATE KEY |
NATURAL KEY | A key which have a real existinence in business logic or have the real value in the world like AADHAR NO in India and SSN NO in USA |