Skip to main content

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 EntityTarget EntityCardinalityFK Column
MngCountryMngAdmin11:Ncountry_id
MngAdmin1MngAdmin21:Nadmin_1_id
MngAdmin2MngLocation1:Nadmin_2_id
MngCountryMngCultivar1:Ncountry_id
MngCropMngCultivar1:Ncrop_id
MngCultivarMngSetup1:Ncultivar_id
MngCountryMngSoil1:Ncountry_id
MngCountryForecast1:Ncountry_id
ForecastForecastAnalogue1:Nforecast_id
MngCountryMngCountryIndicator1:Ncountry_id
MngCountryMngCountryClimateMeasure1:Ncountry_id
MngCountryMngDataSource1:Ncountry_id
MngLocationClimateHistoricalDaily1:Nlocation_id
MngSourceClimateHistoricalDaily1:Nsource_id
MngPhenologicalStagePhenologicalStageStress1:Nphenological_stage_id
MngStressPhenologicalStageStress1:Nstress_id
UserUserAccess1:Nuser_id
MngCountryUserAccess1:Ncountry_id

Integrity Rules​

  • All foreign key relationships have explicit ForeignKey constraints
  • 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
  • enable column (Boolean, default true) implements soft delete across all entities
  • Timestamps (register, updated) are automatically managed via SQLAlchemy defaults