Open lesson

Mission: Voss’s four confirmations

Command palette

This mission workspace keeps code and notes in this browser tab. Export them before closing it. Running code is practice, not an automatic grade for the mission.

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

  1. Write the ON condition using authorization ID and give its pairs.
  2. Give row counts for INNER JOIN and LEFT JOIN with that condition.
  3. Explain the four Noctis pairs made by joining only on vehicle code and the total rows such a join returns.
  4. 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 JOIN returns 3 rows; LEFT JOIN returns 4 including P4–NULL.
  • Vehicle-code linking makes four Noctis combinations, five matches total and six LEFT JOIN rows 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');

Code

Use Tab to leave the editor. Ctrl+Enter runs the source. The lines beginning with -- are task reminders. SQL ignores them. Write your query beneath them.

SQL console

Loading laboratory…

Explore Python or SQL here; this is not an operating-system shell.

This is a disposable browser experiment. The code run here is not recorded as a completed mission.

Each command starts a fresh disposable worker: it runs a captured copy of your current source, then your command with the lesson fixtures. Changes are discarded afterward. Commands never save source or award XP. Ctrl+Enter executes the command.

Virtual workspace files

Source and declarative assets are readable here without JavaScript. Python input files are created at runtime; SQL setup initializes the disposable database.

source.sql

Current editor source. Inspection shows your current edits.

-- Write the `ON` condition using authorization ID and give its pairs.
-- Give row counts for `INNER JOIN` and `LEFT JOIN` with 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.

exemple.sql

Declarative lesson asset; this is not a file created in the Python filesystem.

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;
donnees.sql

Declarative lesson asset; this is not a file created in the Python filesystem.

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');