Only this week, get the SQL Complete Track of 9 courses in a special prize of $330 $89!
Foreign keys
Multicolumn foreign keys
Updates and deletes


If you had done everything correctly, you shouldn't have been able to perform any of the tasks we prepared. The database keeps all information consistent, just as it does in case of single column foreign keys.


Last time we prepared the template code for you, now it's your turn to make it work! Provide the proper code to create the table department shown in the diagram below:

Office and department tables

The columns office_floor and office_building_name should form a single foreign key.

Stuck? Here's a hint!


CREATE TABLE department (
    id int PRIMARY KEY,
    name varchar(1000)  NOT NULL,
    manager_id int  NOT NULL,
    office_floor int  NOT NULL,
    office_building_name varchar(255)  NOT NULL,
    FOREIGN KEY (office_floor,office_building_name) REFERENCES office (floor,building_name)