Brief
Replay a batch already loaded without doubling its events, while flagging a repeated identifier whose values disagree.
Voss points to four report rows as if B1 were delivered twice by independent sources. Imani knows raw B1 contained E7 and TRANSFER-7 and that the pipeline replayed B1 after a stop. Mara gives you an empty practice table with unique event_id. A late TRANSFER-7 also says vehicle = TEST-02 instead of NOCTIS-01. The team needs that contradiction reported.
Your mission
- Give the row count after the first B1 load and after an identical replay using ON CONFLICT.
- Write the clause that prevents a second E7 row.
- Explain what to do when TRANSFER-7 returns with another vehicle but the same ID.
- Give the reference row count after B2 adds new E9, and say what that count cannot prove.
How to check your work
- First load: 2 rows; identical replay: still 2.
- The clause is ON CONFLICT (event_id) DO NOTHING.
- Keep and flag conflicting content instead of silently dropping it.
- New E9 makes 3 rows; the count proves neither authorship nor authenticity.
Course example
CREATE TABLE events (
event_id TEXT PRIMARY KEY,
vehicle TEXT NOT NULL,
source_file TEXT NOT NULL
);
INSERT INTO events VALUES ('E7', 'NOCTIS-01', 'gate-page1.json');
INSERT INTO events VALUES ('TRANSFER-7', 'NOCTIS-01', 'vendor-page2.json');
INSERT INTO events VALUES ('E7', 'NOCTIS-01', 'gate-page1.json')
ON CONFLICT (event_id) DO NOTHING;
INSERT INTO events VALUES ('TRANSFER-7', 'NOCTIS-01', 'vendor-page2.json')
ON CONFLICT (event_id) DO NOTHING;
SELECT COUNT(*) AS stored_rows FROM events;
SELECT event_id, vehicle, source_file FROM events ORDER BY event_id;