Constraints

90 Foreign Key Constraints

Constraint Name Child Column Parent Column Delete Rule
observation_requested_subzones_observation_id_fkey
observation_requested_subzones.observation_id
observations.id
Cascade on delete
observation_requested_subzones_planting_subzone_id_fkey
observation_requested_subzones.planting_subzone_id
planting_subzones.id
Cascade on delete
planting_site_populations_planting_site_id_fkey
planting_site_populations.planting_site_id
planting_sites.id
Cascade on delete
planting_site_populations_species_id_fkey
planting_site_populations.species_id
species.id
Cascade on delete
planting_subzone_populations_planting_subzone_id_fkey
planting_subzone_populations.planting_subzone_id
planting_subzones.id
Cascade on delete
planting_subzone_populations_species_id_fkey
planting_subzone_populations.species_id
species.id
Cascade on delete
observation_plots_modified_by_fkey
observation_plots.modified_by
users.id
Restrict delete
observation_plots_observation_id_fkey
observation_plots.observation_id
observations.id
Cascade on delete
observation_plots_completed_by_fkey
observation_plots.completed_by
users.id
Restrict delete
observation_plots_monitoring_plot_id_fkey
observation_plots.monitoring_plot_id
monitoring_plots.id
Cascade on delete
observation_plots_created_by_fkey
observation_plots.created_by
users.id
Restrict delete
observation_plots_claimed_by_fkey
observation_plots.claimed_by
users.id
Restrict delete
monitoring_plots_modified_by_fkey
monitoring_plots.modified_by
users.id
Restrict delete
monitoring_plots_created_by_fkey
monitoring_plots.created_by
users.id
Restrict delete
monitoring_plots_planting_subzone_id_fkey
monitoring_plots.planting_subzone_id
planting_subzones.id
Cascade on delete
planting_subzone_histories_planting_subzone_id_fkey
planting_subzone_histories.planting_subzone_id
planting_subzones.id
Null on delete
planting_subzone_histories_planting_zone_history_id_fkey
planting_subzone_histories.planting_zone_history_id
planting_zone_histories.id
Cascade on delete
plantings_planting_site_id_plot_id_fkey
plantings.planting_site_id
plantings.planting_subzone_id
planting_subzones.planting_site_id
planting_subzones.id
Restrict delete
plantings_planting_site_id_fkey
plantings.planting_site_id
planting_sites.id
Cascade on delete
plantings_planting_subzone_id_fkey
plantings.planting_subzone_id
planting_subzones.id
Cascade on delete
plantings_planting_site_id_delivery_id_fkey
plantings.planting_site_id
plantings.delivery_id
deliveries.planting_site_id
deliveries.id
Restrict delete
plantings_species_id_fkey
plantings.species_id
species.id
Restrict delete
plantings_delivery_id_fkey
plantings.delivery_id
deliveries.id
Cascade on delete
plantings_planting_type_id_fkey
plantings.planting_type_id
planting_types.id
Restrict delete
plantings_created_by_fkey
plantings.created_by
users.id
Restrict delete
observed_plot_species_totals_observation_id_fkey
observed_plot_species_totals.observation_id
observations.id
Cascade on delete
observed_plot_species_totals_certainty_id_fkey
observed_plot_species_totals.certainty_id
recorded_species_certainties.id
Restrict delete
observed_plot_species_totals_monitoring_plot_id_fkey
observed_plot_species_totals.monitoring_plot_id
monitoring_plots.id
Cascade on delete
observed_plot_species_totals_species_id_fkey
observed_plot_species_totals.species_id
species.id
Restrict delete
planting_seasons_planting_site_id_fkey
planting_seasons.planting_site_id
planting_sites.id
Cascade on delete
observed_zone_species_totals_certainty_id_fkey
observed_zone_species_totals.certainty_id
recorded_species_certainties.id
Restrict delete
observed_zone_species_totals_species_id_fkey
observed_zone_species_totals.species_id
species.id
Restrict delete
observed_zone_species_totals_planting_zone_id_fkey
observed_zone_species_totals.planting_zone_id
planting_zones.id
Cascade on delete
observed_zone_species_totals_observation_id_fkey
observed_zone_species_totals.observation_id
observations.id
Cascade on delete
plots_planting_site_id_planting_zone_id_fkey
planting_subzones.planting_site_id
planting_subzones.planting_zone_id
planting_zones.planting_site_id
planting_zones.id
Restrict delete
plots_created_by_fkey
planting_subzones.created_by
users.id
Restrict delete
plots_planting_zone_id_fkey
planting_subzones.planting_zone_id
planting_zones.id
Cascade on delete
plots_modified_by_fkey
planting_subzones.modified_by
users.id
Restrict delete
plots_planting_site_id_fkey
planting_subzones.planting_site_id
planting_sites.id
Cascade on delete
planting_site_histories_created_by_fkey
planting_site_histories.created_by
users.id
Restrict delete
planting_site_histories_planting_site_id_fkey
planting_site_histories.planting_site_id
planting_sites.id
Cascade on delete
planting_sites_created_by_fkey
planting_sites.created_by
users.id
Restrict delete
planting_sites_modified_by_fkey
planting_sites.modified_by
users.id
Restrict delete
planting_sites_time_zone_fkey
planting_sites.time_zone
time_zones.time_zone
Null on delete
planting_sites_organization_id_fkey
planting_sites.organization_id
organizations.id
Cascade on delete
planting_sites_project_id_fkey
planting_sites.project_id
projects.id
Null on delete
recorded_plants_observation_id_monitoring_plot_id_fkey
recorded_plants.observation_id
recorded_plants.monitoring_plot_id
observation_plots.observation_id
observation_plots.monitoring_plot_id
Cascade on delete
recorded_plants_certainty_id_fkey
recorded_plants.certainty_id
recorded_species_certainties.id
Restrict delete
recorded_plants_species_id_fkey
recorded_plants.species_id
species.id
Restrict delete
recorded_plants_observation_id_fkey
recorded_plants.observation_id
observations.id
Cascade on delete
recorded_plants_monitoring_plot_id_fkey
recorded_plants.monitoring_plot_id
monitoring_plots.id
Cascade on delete
recorded_plants_status_id_fkey
recorded_plants.status_id
recorded_plant_statuses.id
Restrict delete
observations_planting_site_id_fkey
observations.planting_site_id
planting_sites.id
Cascade on delete
observations_state_id_fkey
observations.state_id
observation_states.id
Restrict delete
observed_plot_coordinates_observation_id_monitoring_plot_i_fkey
observed_plot_coordinates.observation_id
observed_plot_coordinates.monitoring_plot_id
observation_plots.observation_id
observation_plots.monitoring_plot_id
Restrict delete
observed_plot_coordinates_position_id_fkey
observed_plot_coordinates.position_id
observation_plot_positions.id
Restrict delete
observed_plot_coordinates_observation_id_fkey
observed_plot_coordinates.observation_id
observations.id
Cascade on delete
observed_plot_coordinates_monitoring_plot_id_fkey
observed_plot_coordinates.monitoring_plot_id
monitoring_plots.id
Cascade on delete
observed_site_species_totals_observation_id_fkey
observed_site_species_totals.observation_id
observations.id
Cascade on delete
observed_site_species_totals_species_id_fkey
observed_site_species_totals.species_id
species.id
Restrict delete
observed_site_species_totals_certainty_id_fkey
observed_site_species_totals.certainty_id
recorded_species_certainties.id
Restrict delete
observed_site_species_totals_planting_site_id_fkey
observed_site_species_totals.planting_site_id
planting_sites.id
Cascade on delete
planting_site_notifications_notification_type_id_fkey
planting_site_notifications.notification_type_id
notification_types.id
Restrict delete
planting_site_notifications_planting_site_id_fkey
planting_site_notifications.planting_site_id
planting_sites.id
Cascade on delete
observation_plot_conditions_observation_id_fkey
observation_plot_conditions.observation_id
observations.id
Cascade on delete
observation_plot_conditions_monitoring_plot_id_fkey
observation_plot_conditions.monitoring_plot_id
monitoring_plots.id
Cascade on delete
observation_plot_conditions_condition_id_fkey
observation_plot_conditions.condition_id
observable_conditions.id
Restrict delete
deliveries_planting_site_id_fkey
deliveries.planting_site_id
planting_sites.id
Cascade on delete
deliveries_reassigned_by_fkey
deliveries.reassigned_by
users.id
Restrict delete
deliveries_created_by_fkey
deliveries.created_by
users.id
Restrict delete
deliveries_modified_by_fkey
deliveries.modified_by
users.id
Restrict delete
deliveries_withdrawal_id_fkey
deliveries.withdrawal_id
withdrawals.id
Cascade on delete
planting_zones_created_by_fkey
planting_zones.created_by
users.id
Restrict delete
planting_zones_modified_by_fkey
planting_zones.modified_by
users.id
Restrict delete
planting_zones_planting_site_id_fkey
planting_zones.planting_site_id
planting_sites.id
Cascade on delete
observation_photos_observation_id_fkey
observation_photos.observation_id
observations.id
Restrict delete
observation_photos_monitoring_plot_id_fkey
observation_photos.monitoring_plot_id
monitoring_plots.id
Restrict delete
observation_photos_position_id_fkey
observation_photos.position_id
observation_plot_positions.id
Restrict delete
observation_photos_observation_id_monitoring_plot_id_fkey
observation_photos.observation_id
observation_photos.monitoring_plot_id
observation_plots.observation_id
observation_plots.monitoring_plot_id
Restrict delete
observation_photos_file_id_fkey
observation_photos.file_id
files.id
Cascade on delete
planting_zone_populations_species_id_fkey
planting_zone_populations.species_id
species.id
Cascade on delete
planting_zone_populations_planting_zone_id_fkey
planting_zone_populations.planting_zone_id
planting_zones.id
Cascade on delete
draft_planting_sites_project_id_fkey
draft_planting_sites.project_id
projects.id
Null on delete
draft_planting_sites_time_zone_fkey
draft_planting_sites.time_zone
time_zones.time_zone
Restrict delete
draft_planting_sites_created_by_fkey
draft_planting_sites.created_by
users.id
Restrict delete
draft_planting_sites_modified_by_fkey
draft_planting_sites.modified_by
users.id
Restrict delete
draft_planting_sites_organization_id_fkey
draft_planting_sites.organization_id
organizations.id
Cascade on delete
draft_planting_sites_organization_id_project_id_fkey
draft_planting_sites.organization_id
draft_planting_sites.project_id
projects.organization_id
projects.id
Restrict delete
planting_zone_histories_planting_zone_id_fkey
planting_zone_histories.planting_zone_id
planting_zones.id
Null on delete
planting_zone_histories_planting_site_history_id_fkey
planting_zone_histories.planting_site_history_id
planting_site_histories.id
Cascade on delete

Check Constraints

Table Constraint Name Constraint
observation_plots cannot_unclaim_completed_plot (((completed_by IS NULL) OR ((completed_by IS NOT NULL) AND (claimed_by IS NOT NULL))))
monitoring_plots cluster_has_subplot ((((permanent_cluster IS NOT NULL) AND (permanent_cluster_subplot IS NOT NULL)) OR ((permanent_cluster IS NULL) AND (permanent_cluster_subplot IS NULL))))
monitoring_plots subplot_is_valid (((permanent_cluster_subplot >= 1) AND (permanent_cluster_subplot <= 4)))
plantings num_plants_sign_consistent_with_type ((((planting_type_id = ANY (ARRAY[2, 4])) AND (num_plants < 0)) OR ((planting_type_id <> ALL (ARRAY[2, 4])) AND (num_plants > 0))))
plantings plantings_notes_check ((notes !~ similar_to_escape(' *'::text)))
observed_plot_species_totals species_identifier_for_certainty ((((certainty_id = 1) AND (species_id IS NOT NULL) AND (species_name IS NULL)) OR ((certainty_id = 2) AND (species_id IS NULL) AND (species_name IS NOT NULL)) OR ((certainty_id = 3) AND (species_id IS NULL) AND (species_name IS NULL))))
planting_seasons planting_seasons_check ((start_date < end_date))
planting_seasons planting_seasons_check1 ((start_time < end_time))
observed_zone_species_totals species_identifier_for_certainty ((((certainty_id = 1) AND (species_id IS NOT NULL) AND (species_name IS NULL)) OR ((certainty_id = 2) AND (species_id IS NULL) AND (species_name IS NOT NULL)) OR ((certainty_id = 3) AND (species_id IS NULL) AND (species_name IS NULL))))
planting_subzones area_positive ((area_ha > (0)::numeric))
planting_sites area_positive ((area_ha > (0)::numeric))
planting_sites planting_sites_description_check ((description !~ similar_to_escape(' *'::text)))
recorded_plants species_info_matches_certainty ((((certainty_id = 1) AND (species_id IS NOT NULL) AND (species_name IS NULL)) OR ((certainty_id = 2) AND (species_id IS NULL)) OR ((certainty_id = 3) AND (species_id IS NULL) AND (species_name IS NULL))))
observations completed_time_and_state ((((completed_time IS NULL) AND (state_id <> 3)) OR ((completed_time IS NOT NULL) AND (state_id = 3))))
observations end_after_start ((start_date <= end_date))
observed_site_species_totals species_identifier_for_certainty ((((certainty_id = 1) AND (species_id IS NOT NULL) AND (species_name IS NULL)) OR ((certainty_id = 2) AND (species_id IS NULL) AND (species_name IS NOT NULL)) OR ((certainty_id = 3) AND (species_id IS NULL) AND (species_name IS NULL))))
planting_zones area_positive ((area_ha > (0)::numeric))
planting_zones must_have_permanent_clusters ((num_permanent_clusters > 0))
planting_zones must_have_temporary_plots ((num_temporary_plots > 0))
planting_zones positive_target_density ((target_planting_density > (0)::numeric))