What is the Difference between a Primary Key and a 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 accepts the duplicate value and never accept null values.
Foreign Key:- Foreign Key is a column/columns in the table which is already defined as a primary/unique key in an another/same table.
1) Primary Key is used for uniquely identified the record whereas the Foreign key is to ensure the column values referenced from Primary key column
2) Primary Key never accept Null value whereas Foreign Key accept Null Value
3) In a table, only 1 Primary Key can be defined whereas more than 1 foreign key can be defined in a table.
4) Primary never accept duplicate values whereas Foreign accept duplicate records
Primary Key:- Primary Key is a column/columns in a table which can uniquely identify the records, it never accepts the duplicate value and never accept null values.
Foreign Key:- Foreign Key is a column/columns in the table which is already defined as a primary/unique key in an another/same table.
1) Primary Key is used for uniquely identified the record whereas the Foreign key is to ensure the column values referenced from Primary key column
2) Primary Key never accept Null value whereas Foreign Key accept Null Value
3) In a table, only 1 Primary Key can be defined whereas more than 1 foreign key can be defined in a table.
4) Primary never accept duplicate values whereas Foreign accept duplicate records
0 comments:
Post a Comment