Open lesson

Mission: the vehicle changes in the report

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 each event to the registry version valid at the event time and spot labels with no matching version.

Voss displays a report screenshot claiming the prototype was on the road during the crash. Mara lays two label records on the table, separated at 20:00 UTC. Imani gives you R1 at 19:30 and R2 at 21:25; both say NOCTIS-01. Explain clearly why attaching the older record to R2 is misleading before the screenshot spreads further. The urgency is part of the story; the exercise has no timer.

Your mission

  1. Assign R1 and R2 to their correct registry periods.
  2. Write the two time comparisons needed for a temporal join.
  3. Explain how LEFT JOIN and time conditions in ON expose events without a registry match.
  4. State an accurate conclusion about R2 and a check still needed.

How to check your work

  • R1 matches PROTOTYPE-01 and R2 matches SHELL-02 in the copy.
  • event_at >= valid_from and event_at < valid_to, except for NULL end.
  • An unmatched fact remains with NULL for the joined asset.
  • The source links R2 to a shell; the physical object still needs corroboration.

Course example

CREATE TABLE road_events (
    event_id TEXT PRIMARY KEY,
    event_at TEXT NOT NULL,
    vehicle_label TEXT NOT NULL
);
CREATE TABLE label_history (
    vehicle_label TEXT NOT NULL,
    physical_asset TEXT NOT NULL,
    valid_from TEXT NOT NULL,
    valid_to TEXT
);
INSERT INTO road_events VALUES
    ('R1', '2026-04-12T19:30:00Z', 'NOCTIS-01'),
    ('R2', '2026-04-12T21:25:00Z', 'NOCTIS-01');
INSERT INTO label_history VALUES
    ('NOCTIS-01', 'PROTOTYPE-01', '2026-04-01T00:00:00Z', '2026-04-12T20:00:00Z'),
    ('NOCTIS-01', 'SHELL-02', '2026-04-12T20:00:00Z', NULL);

SELECT e.event_id, e.event_at, h.physical_asset
FROM road_events AS e
LEFT JOIN label_history AS h
  ON e.vehicle_label = h.vehicle_label
 AND e.event_at >= h.valid_from
 AND (h.valid_to IS NULL OR e.event_at < h.valid_to)
ORDER BY e.event_id;

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.

-- Assign R1 and R2 to their correct registry periods.
-- Write the two time comparisons needed for a temporal join.
-- Explain how LEFT JOIN and time conditions in ON expose events without a registry match.
-- State an accurate conclusion about R2 and a check still needed.

exemple.sql

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

CREATE TABLE road_events (
    event_id TEXT PRIMARY KEY,
    event_at TEXT NOT NULL,
    vehicle_label TEXT NOT NULL
);
CREATE TABLE label_history (
    vehicle_label TEXT NOT NULL,
    physical_asset TEXT NOT NULL,
    valid_from TEXT NOT NULL,
    valid_to TEXT
);
INSERT INTO road_events VALUES
    ('R1', '2026-04-12T19:30:00Z', 'NOCTIS-01'),
    ('R2', '2026-04-12T21:25:00Z', 'NOCTIS-01');
INSERT INTO label_history VALUES
    ('NOCTIS-01', 'PROTOTYPE-01', '2026-04-01T00:00:00Z', '2026-04-12T20:00:00Z'),
    ('NOCTIS-01', 'SHELL-02', '2026-04-12T20:00:00Z', NULL);

SELECT e.event_id, e.event_at, h.physical_asset
FROM road_events AS e
LEFT JOIN label_history AS h
  ON e.vehicle_label = h.vehicle_label
 AND e.event_at >= h.valid_from
 AND (h.valid_to IS NULL OR e.event_at < h.valid_to)
ORDER BY e.event_id;