A foreign key points to the primary key of another table or A foreign key represent the value of a primary key in a related table. While primary keys must contain unique values, foreign keys may have duplicates.
For instance, if we use student ID as the primary key in a Students table (each student has a unique ID), we could use student ID as a foreign key in a Courses table: as each student may do more than one course, the student ID field in the Courses table (often shortened to Courses.student ID) will hold duplicate values
The purpose of the foreign key is to maintain referential integrity of the data.
For instance, if we use student ID as the primary key in a Students table (each student has a unique ID), we could use student ID as a foreign key in a Courses table: as each student may do more than one course, the student ID field in the Courses table (often shortened to Courses.student ID) will hold duplicate values
The purpose of the foreign key is to maintain referential integrity of the data.
No comments:
Post a Comment