What is Foreign Key?
A foreign key is a column or group of columns in a relational database table that provides a link between data in two tables. It is a column (or columns) that references a column (most often the primary key) of another table.
Example: STUD_NO in STUDENT_COURSE is a foreign key to STUD_NO in STUDENT relation.
Difference between Primary Key and Foreign Key
Pre-Requisite: Relational Database Model
Keys are one of the most important elements in a relational database to maintain the relationship between the tables and it also helps in uniquely identifying the data from a table. The primary Key is a key that helps in uniquely identifying the tuple of the database whereas the Foreign Key is a key that is used to identify the relationship between the tables through the primary key of one table that is the primary key one table acts as a foreign key to another table. Now, let’s discuss both of them in some detail.