A makerspace keeps people in makers and their session choices in bookings. Join the identifiers so each booking gains a readable name. Inez should appear twice because she booked two different sessions.
These tables are already loaded at the start of this lesson.
bookingsOne row represents one booked session choice.
| Field / SQL type | Meaning | Rules |
|---|---|---|
booking_id · integer | Identifier of this booking, not of a person. | Primary key. Required; cannot be NULL. |
maker_id · integer | Person identifier used to match this booking to makers. | Nullable; NULL means the identifier is unrecorded. |
session · text | Booked session label; not a separate session identifier. | Nullable; NULL means no session value is recorded. |
makersOne row represents one person in the makerspace.
| Field / SQL type | Meaning | Rules |
|---|---|---|
maker_id · integer | Identifier of the person. | Primary key. Required; cannot be NULL. |
name · text | Person display name; different people may share a name. | Nullable; NULL means no name value is recorded. |
bookings.maker_id matches makers.maker_id. One makers row can have zero or many matching bookings rows; each bookings row can match zero or one parent because the parent key is unique. This is a logical match, not a declared foreign key; a NULL or unmatched child identifier is allowed.
In the supplied rows, Inez has two bookings, Jules has one, and Kai has none. Joining child detail repeats the parent fields once per matching child. An inner join omits unmatched rows; a left join keeps unmatched rows from its left input with NULLs for the missing side. Those result NULLs are separate from missing values stored in a real row.
The setup below is already loaded before each attempt. It is reference material, not code to paste into script.sql.
CREATE TABLE makers (maker_id integer PRIMARY KEY, name text);
CREATE TABLE bookings (booking_id integer PRIMARY KEY, maker_id integer, session text);
INSERT INTO makers VALUES (1,'Inez'),(2,'Jules'),(3,'Kai');
INSERT INTO bookings VALUES (21,1,'Woodwork'),(22,1,'Repair'),(23,2,'Printing');
Edit script.sql, use Run to inspect the result, then Submit.
name and booked session for every booking, using the maker_id relationship. Order by booking_id.| name | session |
|---|---|
| Inez | Woodwork |
| Inez | Repair |
| Jules | Printing |
Match the foreign identifier to the person's unique key.