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

Instruction

Nice! Let's tackle another problem.

Exercise

Based on the ERD below, create the purchase_position table.

LEAD

Stuck? Here's a hint!

Type:

CREATE TABLE purchase_position (
  purchase_id integer NOT NULL,
  item_id integer NOT NULL,
  seq integer NOT NULL,
  PRIMARY KEY (purchase_id, item_id, seq),
  FOREIGN KEY (purchase_id)
    REFERENCES purchase(id),
  FOREIGN KEY (item_id)
    REFERENCES item(id)
);