Table constraints - FOREIGN KEY
59.3 - Ex 1
Exercise

FOREIGN KEY - 1

The table courses below consists of columns id, name and abbreviatedName with id as PRIMARY KEY.

Write a set of statements to:

  1. create a new table books with the following columns, data types and constraints.

    column data type constraint
    id INTEGER PRIMARY KEY
    name TEXT NOT NULL
    courseId INTEGER FOREIGN KEY on id in courses
  2. add these record rows to the created table books, in the given order.

    id (INTEGER) name (TEXT) courseId (INTEGER)
    1 Basics of Ruby 4
    2 Basics of SQL 7