Primary and foreign keys
Primary key
A primary key is a field used to uniquely identify every record in the database. Sometime primary keys are obvious, for example a car license plate could be used to uniquely identify cars. Often, primary keys are less obvious and it is necessary to create a unique value 鈥 often an ID number.
A primary key is a guaranteed way of uniquely identifying each record. In the school example, the primary key used to identify each member of staff in the teacher table is Staff ID.
Foreign key
A foreign key is a primary key from one table that appears in another table to link the two together. The Department ID is the primary key in the Department table that appears as a foreign key in the Teacher table to link the two.