Difference between Primary key, Foreign key, super key and Candidate key.


Primary Key: It is define as a unique combination of attribute from a table which will identify all the tuple uniquely through out the Table. To identify the primary key in table , we first found out super key and then Candidate key where candidate key serve as primary key.



For example: Employee id is the primary key in the Employee table. Primary key is identify by the underline(_) symbol.  

Super Key: It is define as a set of attributes which identify every tuple uniquely. Example of super key from employee table is follow:
Super Key : {emp_id}, {emp_id, emp_name}.

Candidate Key : It is define as set of minimum number of attributes which identifies every tuple uniquely.  Example of Candidate key from employee table is follow:
Candidate Key : {emp_id}.


Minimality Property :  A super key with minimum number of attributes is known as Candidate key and minimality property is, from a set which is identify tuple uniquely. If we remove any attribute then uniqueness property should be lost. 

Every Candidate Key = Super Key
Every Super Key != Candidate Key

Foreign Key : It is define as a share key from a table  which is acting as a strong entity. Such a key is used by a week entities to establish relationship with the strong entities on which week entities are dependent, such key are the primary key into the strong entities. 

Lets understand with the help of tables.                 

Prod_id is the primary key in table Product but  in orders table, it represent the foreign key.






    


Comments

Popular posts from this blog

Introduction to Python.

Decision Making Statement.