Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Foreign keys
Multicolumn foreign keys
Updates and deletes
Revision
24. Revision - #1

Instruction

That's it! You've mastered everything we prepared for you in this part. How about a few quick exercises before we let you go?

Exercise

At the university, there are courses and lecturers. Each course is led by a specific lecturer.

Create a table course with the following columns:

  • id - integer, primary key,
  • title - up to 64 characters,
  • is_obligatory - a true/false field,
  • lecturer_id - an integer. It is a foreign key referring to column id from the table lecturer.

Stuck? Here's a hint!

Type:

CREATE TABLE course (
  id int PRIMARY KEY,
  title varchar(64),
  is_obligatory boolean,
  lecturer_id int,
  FOREIGN KEY(lecturer_id) REFERENCES lecturer(id)
);