Showing posts with label Primary Key and Foreign Key. Show all posts
Showing posts with label Primary Key and Foreign Key. Show all posts

Primary Key and Foreign Key

 

Primary Key and Foreign Key

Difference between Primary Key and Foreign Key:-

Primary Key :- Primary Key is a column/columns in a table which can uniquely identify the records, it never accept duplicate value and never accept null values.

Foreign Key :- Foreign Key is a column/columns in table which is already defined as a primary/unique key in a another/same table.

1) Primary Key is used for uniquely identified the record where as Foreign key is to ensure the column values referenced from Primary key column

2) Primary Key never accept Null value where as Foreign Key accept Null Value

3) In a table only 1 Primary Key can be defined where as more than 1 foreign key can be defined in a table.

4) Primary never accept duplicate values where as Foreign accept duplicate records