Each live parameter/quality row → its *Snapshot rows: one-to-many, with the
snapshot's back-reference nullable (SET NULL)
Notes
All primary keys are UUIDs. UK = unique constraint, FK = foreign key.
Deletes cascade down the ownership tree. Deleting an event removes its
seismograms, parameters, quality, snapshots, and every snapshot sub-row;
deleting a seismogram removes its data source, parameters, and quality;
deleting a snapshot removes its four sub-rows. A note is removed with its
parent.
Snapshot → live-record links use SET NULL, not cascade.AimbatEventParametersSnapshot.parameters_id,
AimbatSeismogramParametersSnapshot.seismogram_parameters_id, and the two
quality equivalents go NULL when the live row is deleted, so historical
snapshots survive. The seismogram-level snapshot tables also keep their own
denormalised seismogram_id for the same reason.
One-to-one links are DB-enforced by unique indexes on
AimbatEventParameters.event_id, AimbatSeismogramParameters.seismogram_id,
AimbatEventQuality.event_id, AimbatSeismogramQuality.seismogram_id, and
AimbatDataSource.sourcename.
AimbatSnapshot is keyed by (event_id, sequence). sequence is a
monotonic per-event counter that defines snapshot order. mccc_hash /
iccs_hash are SHA-256 of the parameters affecting each algorithm's output at
capture time; both null until those parameters exist.
AimbatNote holds exactly one of event_id / station_id /
seismogram_id / snapshot_id (a CHECK constraint), with a partial unique
index per FK so a parent has at most one note.
AimbatEvent.stack_modified bumps only on parameters that force an ICCS
rebuild (event window, ramp, bandpass, corners; per-seismogram t1 / flip /
select); last_modified bumps on any parameter change. Both are maintained
by triggers, alongside the quality-nulling triggers in
Quality metric invalidation.
The *Snapshot parameter and quality tables inherit every column from the
same base class as their live counterpart (AimbatEventParametersBase,
AimbatSeismogramParametersBase, AimbatEventQualityBase,
AimbatSeismogramQualityBase); only their structural columns are shown above.
```