Entity Relationships
This page describes the key relationships between entities in the AClimate v3 data model.
Geographic Hierarchy
MngCountry
├── MngAdmin1 (country_id FK)
│ └── MngAdmin2 (admin_1_id FK)
│ └── MngLocation (admin_2_id FK)
├── MngCultivar (country_id FK)
├── MngSoil (country_id FK)
├── MngCountryIndicator (country_id FK)
├── MngCountryClimateMeasure (country_id FK)
├── MngDataSource (country_id FK)
├── UserAccess (country_id FK)
└── Forecast (country_id FK)
Crop Configuration Chain
MngCrop
└── MngCultivar (crop_id FK)
└── MngSetup (cultivar_id FK)
Phenology & Stress
MngPhenologicalStage
└── PhenologicalStageStress (phenological_stage_id FK)
└── MngStress (stress_id FK)
Forecast Domain
MngCountry
└── Forecast (country_id FK)
└── ForecastAnalogue (forecast_id FK)
Climate Data
MngLocation
├── ClimateHistoricalDaily (location_id FK) → MngSource (source_id FK)
├── ClimateHistoricalMonthly (location_id FK)
├── ClimateHistoricalClimatology (location_id FK)
└── ClimateHistoricalIndicator (location_id FK)
Security Model
User
├── Role (via user_role association)
└── UserAccess (user_id FK) → MngCountry
Cardinality Summary
| Source Entity | Target Entity | Cardinality | FK Column |
|---|---|---|---|
| MngCountry | MngAdmin1 | 1:N | country_id |
| MngAdmin1 | MngAdmin2 | 1:N | admin_1_id |
| MngAdmin2 | MngLocation | 1:N | admin_2_id |
| MngCountry | MngCultivar | 1:N | country_id |
| MngCrop | MngCultivar | 1:N | crop_id |
| MngCultivar | MngSetup | 1:N | cultivar_id |
| MngCountry | MngSoil | 1:N | country_id |
| MngCountry | Forecast | 1:N | country_id |
| Forecast | ForecastAnalogue | 1:N | forecast_id |
| MngCountry | MngCountryIndicator | 1:N | country_id |
| MngCountry | MngCountryClimateMeasure | 1:N | country_id |
| MngCountry | MngDataSource | 1:N | country_id |
| MngLocation | ClimateHistoricalDaily | 1:N | location_id |
| MngSource | ClimateHistoricalDaily | 1:N | source_id |
| MngPhenologicalStage | PhenologicalStageStress | 1:N | phenological_stage_id |
| MngStress | PhenologicalStageStress | 1:N | stress_id |
| User | UserAccess | 1:N | user_id |
| MngCountry | UserAccess | 1:N | country_id |
Integrity Rules
- All foreign key relationships have explicit
ForeignKeyconstraints - Cascade behavior:
- DELETE-ORPHAN: MngCountryIndicator, MngCountryClimateMeasure (cascade delete on parent)
- RESTRICT: Most other relationships (prevents accidental deletion of referenced entities)
- Required fields (
NOT NULL) ensure data completeness at the database level enablecolumn (Boolean, default true) implements soft delete across all entities- Timestamps (
register,updated) are automatically managed via SQLAlchemy defaults