Difference between Primary Key and Foreign Key
A primary key is used to ensure data in the specific column is unique. It is a column that cannot have NULL values. It is either an existing table column or a column that is specifically generated by the database according to a defined sequence.
What is Primary key:
Example: Refer to the image above:
STUD_NO, as well as STUD_PHONE both, are candidate keys for relation STUDENT but STUD_NO can be chosen as the primary key (only one out of many candidate keys).
What is a Foriegn key:
Example: Refer to the above image
STUD_NO in STUDENT_COURSE is a foreign key to STUD_NO in STUDENT relation.… Continue Reading