A field in one table that links to the primary key of another table, establishing a relationship between the two tables.
Foreign keys are how relational databases connect related data across tables. Instead of repeating information in every row, you store it once in a reference table and use a foreign key to point to it. This keeps data consistent and avoids duplication.
Example: A dataset of building permits has a column called municipality_id. That column is a foreign key that references the id column in a separate municipalities table. To get the municipality name, you join the two tables on that key.
Foreign keys enforce referential integrity — you cannot add a permit record for a municipality that does not exist in the municipalities table. This prevents orphaned records and data inconsistencies.