Exercise

For this exercise I've created a db fiddle that sets up a departments table for you:

| id INTEGER PRIMARY KEY | name TEXT | department_lead TEXT |
| ---------------------- | --------- | -------------------- |


Create another table for employees that references the one I've created.

The new table should have these columns:


Solution


CREATE TABLE employees (
    id INTEGER PRIMARY KEY,
    first_name TEXT,
    surname TEXT,
    department_id INTEGER,
    FOREIGN KEY (department_id) REFERENCES departments(id)
);


You can also check the solution here.