Example & Tutorial understanding programming in easy ways.

Difference between Primary key and foreign Key ?

The differences between these two keys are mentioned below:

-The primary key uniquely identifies a record, whereas foreign key refers to the primary key of another table. 

-The primary key can never accept a NULL value but foreign key accepts a NULL value. 

-When a record is inserted in a table that contains the primary key then it is not necessary to insert the value on the table that contains this primary key field as the foreign key. 

-When a record is deleted from the table that contains the primary key then the corresponding record must be deleted from the table containing the foreign key for data consistency. 

-But any record can be deleted from the table that contains a foreign key without deleting a related record of another table.

Read More →
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!