A foreign key is a field in a database table that creates a link between two tables. It refers to the primary key of another table, establishing a relationship between the two. This relationship helps maintain data integrity by ensuring that the value in the foreign key field matches a value in the primary key field of the related table.
For example, in a database with a table for Customers and another for Orders, the Orders table might include a foreign key that links to the CustomerID in the Customers table. This setup ensures that each order is associated with a valid customer.