That's right. Okay, time to move on. So far, we've created foreign keys on single columns. We know, however, that primary keys may comprise multiple columns, so there must be a way to create multiple column foreign keys too.
Let's say we have a new table called
office which describes a physical location of an office in a given building on a given floor:
Let's say the primary key will consist of two columns:
building_name. There may be many offices on the third floor in various building and there may be many offices on different floors in one building, but together, these values form a primary key. We'll now learn how to create the proper multicolumn foreign key for this situation. Take a look, you just need to provide all the columns in the parentheses:
FOREIGN KEY (office_floor,office_building_name)
REFERENCES office (floor,building_name)
office_building_name will form a multicolumn foreign key. Excellent!