A foreign key is the linking pin between two tables. The foreign key is the field that links a related table to the main table. It is an attribute in tables whose value match a primary key in another table.
- If a primary key field of one table also appear in other tables then the particular field in other tables is called a foreign key.
- In a foreign key reference, a link is created between two tables when the column or columns that hold the primary key value for one table are referenced by the column or columns in another table. This column becomes a foreign key in the second table.
- The foreign key is used to establish and enforce a link between the data in two tables.