The
derivedprofilepresenceinsoilbodytable defines a many-to-many relationship between soil profiles and soil bodies, linking thesoilprofileandsoilbodytables. This relationship allows a soil profile to be associated with one or more soil bodies and, conversely, enables a single soil body to include multiple soil profiles. The table also stores information on the relative presence of each derived soil profile within a soil body, expressed as a range of percentages (lower and upper boundaries). When a soil body is characterized by more than one derived profile, the spatial distribution of these profiles is not explicitly defined; instead, their contribution is described through percentage ranges indicating their share in the overall soil body.
derivedprofilepresenceinsoilbody| Name | Type | Constraints | Description |
|---|---|---|---|
id |
INTEGER |
PRIMARY KEY | Primary Key of the Table. |
guid_soilbody |
TEXT |
NOT NULL | Foreign key to the SoilBody table. |
guid_soilprofile |
TEXT |
NOT NULL | Foreign key to the SoilProfile table, guid field. |
lowervalue |
REAL |
Upper value. | |
uppervalue |
REAL |
Lower value. |
derivedprofilepresenceinsoilbody.guid_soilprofile → soilprofile.guid (ON UPDATE CASCADE, ON DELETE CASCADE)
soilprofile cascades to derivedprofilepresenceinsoilbody.derivedprofilepresenceinsoilbody.guid_soilbody → soilbody.guid (ON UPDATE CASCADE, ON DELETE CASCADE)
soilbody cascades to derivedprofilepresenceinsoilbody.For every trigger you will find:
i_cecklowervaluesum / u_cecklowervaluesumWhen they run: BEFORE INSERT / BEFORE UPDATE
What they do: For the same guid_soilbody, compute the cumulative lowervalue across existing rows. On insert, it evaluates SUM(lowervalue) + NEW.lowervalue; on update, it evaluates SUM(lowervalue) - OLD.lowervalue + NEW.lowervalue. The total must be ≤ 100.00.
If the check passes: Statement proceeds.
If the check fails: Aborts with: Table derivedprofilepresenceinsoilbody: sum of lowervalue exceeds 100 for the same guid_soilbody.
i_checkisderived_soilbody / u_checkisderived_soilbodyWhen they run: BEFORE INSERT / BEFORE UPDATE
What they do: Ensure guid_soilprofile references a DERIVED profile (isderived = 1).
If the check passes: Statement proceeds.
If the check fails: Aborts with: Table derivedprofilepresenceinsoilbody: Attention, the value of the "guid_soilprofile" field cannot be inserted because profile is not of type derived.