Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
Loading…
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
Loading…
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
SQL / POSTGRESQL / Learn / LESSON 04
A foreign key links a child row to a parent. One author has many books (1:N). authors already exists — create books with author_id REFERENCES authors(id) and insert a valid row.
Small example:
CREATE TABLE books ( id INTEGER PRIMARY KEY, title TEXT NOT NULL, author_id INTEGER NOT NULL REFERENCES authors(id) ); INSERT INTO books (id, title, author_id) VALUES (1, 'Notes', 1);
Starting tables for this task. Grading checks final state on other datasets too.
| id | name |
|---|---|
| 1 | Ada |
| 2 | Grace |
Expected verify columns: column_name, id, title, author_id · row order is checked
Expected final state (displayed data):
Loading…A foreign key links a child row to a parent. One author has many books (1:N). authors already exists — create books with author_id REFERENCES authors(id) and insert a valid row.
QUERY STANDBY
›