The
isderivedfromtable models a dependency relationship between DERIVED and OBSERVED soil profiles.
It implements a self-referential relationship on thesoilprofiletable, allowing soil profiles to be linked to each other according to their role (derived or observed). Specifically, the table associates each derived soil profile (guid_base) with one or more observed soil profiles (guid_related) from which the derived profile has been constructed or inferred, making the data provenance and the conceptual link between point observations and reference profiles explicit.
From a conceptual perspective:
The relationship is therefore many-to-many (N:M) between derived and observed soil profiles and is specialised by rules that enforce semantic consistency between the roles of the linked profiles.
isderivedfrom| Name | Type | Constraints | Description |
|---|---|---|---|
id |
INTEGER |
PRIMARY KEY | Primary Key of the Table. |
guid_base |
TEXT |
NOT NULL | Foreign key to the SoilProfile table, guid field. - Observed Soil Profile. |
guid_related |
TEXT |
NOT NULL | Foreign key to the SoilProfile table, guid field. - Derived Soil Profile. |
isderivedfrom.guid_related → soilprofile.guid (ON UPDATE CASCADE, ON DELETE CASCADE)
soilprofile cascades to isderivedfrom.isderivedfrom.guid_base → soilprofile.guid (ON UPDATE CASCADE, ON DELETE CASCADE)
soilprofile cascades to isderivedfrom.For every trigger you will find:
i_checkisderived / u_checkisderivedWhen they run: BEFORE INSERT / BEFORE UPDATE
What they do: For guid_base, ensure the referenced profile in soilprofile has isderived = 1 (DERIVED).
If the check passes: Statement proceeds.
If the check fails: Aborts with: Table isderivedfrom: Attention, the value of the "guid_base" field in the "isderivedfrom" table cannot be inserted because profile is not of type derived.
i_checkisobserved / u_checkisobservedWhen they run: BEFORE INSERT / BEFORE UPDATE
What they do: For guid_related, require the referenced profile in soilprofile to have isderived = 0 (OBSERVED).
If the check passes: Statement proceeds.
If the check fails: Aborts with: Table isderivedfrom: Attention, the value of the "guid_related" field in the "isderivedfrom" table cannot be inserted because profile is not of type observed.