The key difference between foreign key and primary key is that foreign key is a column or a set of columns that refer to a primary key or a candidate key of another table while primary key is a column or a set of columns that can be used to uniquely identify a row in a table.
A column or a set of columns that can be used to identify or access a row or a set of rows in a database is called a key. A primary key in a relational database is a combination of columns in a table that uniquely identify a row of the table. Foreign key in a relational database is a field in a table that matches the primary key of another table. The foreign key is used to cross reference tables.