Brief
Link passages and authorizations on a precise key, keep unmatched passages visible and spot rows produced by a vague link.
In the story, Voss enters with four Noctis pairs and demands your suspension before the meeting ends. Imani lets you show the fictional tables: passages P1 Noctis A1, P2 Noctis A2, P3 Test-02 A3, P4 Unknown without authorization; authorizations A1 Noctis, A2 Noctis, A3 Test-02. Mara asks you to reconstruct the pairs and preserve P4.
Your mission
- Write the
ONcondition using authorization ID and give its pairs. - Give row counts for
INNER JOINandLEFT JOINwith that condition. - Explain the four Noctis pairs made by joining only on vehicle code and the total rows such a join returns.
- State what must be checked before concluding that a person authorized an exit.
How to check your work
- The condition is
p.authorization_id = a.id; P1–A1, P2–A2, P3–A3 and unmatched P4. INNER JOINreturns 3 rows;LEFT JOINreturns 4 including P4–NULL.- Vehicle-code linking makes four Noctis combinations, five matches total and six
LEFT JOINrows with P4. - Keys, sources and originals need checking; no joined result alone identifies a person.
Course example
SELECT p.id AS passage, p.vehicle, a.id AS authorization FROM passages AS p LEFT JOIN authorizations AS a ON p.authorization_id = a.id;
SQLite schema and synthetic input
CREATE TABLE passages (id TEXT PRIMARY KEY, vehicle TEXT, authorization_id TEXT);
CREATE TABLE authorizations (id TEXT PRIMARY KEY, vehicle TEXT);
INSERT INTO passages VALUES ('P1', 'NOCTIS-01', 'A1'), ('P2', 'NOCTIS-01', 'A2'), ('P3', 'TEST-02', 'A3'), ('P4', 'UNKNOWN', NULL);
INSERT INTO authorizations VALUES ('A1', 'NOCTIS-01'), ('A2', 'NOCTIS-01'), ('A3', 'TEST-02');