Instruction
Great! As you can see, it's not difficult to create a multicolumn foreign key. Let's see how it works in practice.
Exercise
It's time to play around with the new foreign key. Take a look at the tables and try the following things:
- Insert a new department with an
office_floorwhich doesn't exist. - Try to update an existing row in the table
departmentand change theoffice_building_nameto a value which doesn't exist in the table office. - 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;



