Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Foreign keys
Multi-column Foreign Keys
Summary

Instruction

If you did 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 the case of single-column foreign keys.

Exercise

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

LEAD

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

Stuck? Here's a hint!

Type:

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