Only this week, get the SQL Complete Track of 9 courses in a special prize of $330 $89!
6. Adding incorrect data - explained
Foreign keys
Multicolumn foreign keys
Updates and deletes


The insertion succeeded, although we don't have an employee with id 10 in the database. How is it possible that we could 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 table employee but that's it. The database doesn't know about that agreement. For our database, it's just another column of integer type, so it can't check whether the values are correct.

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


Press the Next exercise button to continue.