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
Multi-column Foreign Keys
Summary

Instruction

Let's go through 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: IDs, first names, last names, etc.

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

Exercise

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