Foreign keys
Multicolumn foreign keys
Updates and deletes


Great! As you can see, it's not difficult to create a multicolumn foreign key. Let's see how it works in practice.


It's time to play around with the new foreign key. Take a look at the tables and try the following things:

  1. Insert a new department with an office_floor which doesn't exist.
  2. Try to update an existing row in the table department and change the office_building_name to a value which doesn't exist in the table office.
  3. Update a row in the table office. Change either the floor or the building name and see what happens.

Stuck? Here's a hint!

Here are some example instructions:

1. INSERT INTO department VALUES (10, 'Customer Service', 2, 3, 'Skyline');
2. UPDATE department SET office_building_name = 'Example' WHERE office_building_name = 'Zebra';
3. UPDATE office SET floor = 5 WHERE floor = 3;