Instruction
Great! As you might have noticed, it's not that difficult to create a multi-column 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 tasks:
- Insert a new department with an
office_floorthat doesn't exist. - Try to update an existing row in the
departmenttable, and change theoffice_building_nameto a value that doesn't exist in theofficetable. - Update a row in the
officetable. Change either the floor or the building name and see what happens.
Stuck? Here's a hint!
Here are some example instructions:
INSERT INTO department VALUES (10, 'Customer Service', 2, 3, 'Skyline');
UPDATE department SET office_building_name = 'Example' WHERE office_building_name = 'Zebra';
UPDATE office SET floor = 5 WHERE floor = 3;



