A foreign key is a column that references the primary key of another table. It must match a value in the referenced primary key. Unlike primary keys, foreign keys can contain null values. Primary keys uniquely identify rows in a table, while foreign keys reference primary keys to link data between tables.