Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
2. Referring to one table from another
Foreign keys
Multicolumn foreign keys
Updates and deletes
Revision

Instruction

Let's introduce an example to make things easier to understand.

Our database already contains a table called employee. In this table, we keep data about our employees: their ids, first and last names etc.

We want to add a new table called project. Each project has its own id, name, budget and a manager_id. The manager_id column in the project table will contain the id of the employee from the table employee who is going to be in charge of the project. Well, nothing particular so far.

Exercise

We've already got the table employee, so let's run the template code to create the table project.