Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
5. Adding incorrect data – explained
Foreign keys
Multi-column Foreign Keys
Summary

Instruction

The insertion succeeded, although we don't have an employee with id 10 in the database! How was it possible for us to add 10 as the value for the column manager_id?

The answer is quite simple. We agreed that the column manager_id will contain a value from the column id in the employee table, but that's about it. The database doesn't know about that agreement. For the database, it's just another column of type integer, so it can't check whether the values are correct.

Are we out of luck, then? Not really. This is exactly the place where foreign keys come in handy.

Exercise

Click the Next exercise button to continue.