Primary Key
The primary key is the candidate key that is selected by the database designer as the principal denotes of identifying entities within an entity set. The left candidate keys, if any, are called as alternate keys.
Foreign Keys
Let us first tell you the basic definition of foreign key.
Let R2 be a relation, then a foreign key in R2 is a subset of the set of attributes of R2, such that:
1. There be a relation R1 (R1 and R2 not essentially distinct) with a candidate key, and
2. For all time, every value of a foreign key in the present state or instance of R2 is identical to the value of Candidate Key in a few tuple in the present state of R1.