Constraints

63 Foreign Key Constraints

Constraint Name Child Column Parent Column Delete Rule
organization_managed_location_types_organization_id_fkey
organization_managed_location_types.organization_id
organizations.id
Cascade on delete
organization_managed_location_typ_managed_location_type_id_fkey
organization_managed_location_types.managed_location_type_id
managed_location_types.id
Restrict delete
notification_types_notification_criticality_id_fkey
notification_types.notification_criticality_id
notification_criticalities.id
Restrict delete
user_preferences_user_id_fkey
user_preferences.user_id
users.id
Restrict delete
user_preferences_organization_id_fkey
user_preferences.organization_id
organizations.id
Cascade on delete
organization_report_settings_organization_id_fkey
organization_report_settings.organization_id
organizations.id
Cascade on delete
project_report_settings_project_id_fkey
project_report_settings.project_id
projects.id
Cascade on delete
project_land_use_model_types_land_use_model_type_id_fkey
project_land_use_model_types.land_use_model_type_id
land_use_model_types.id
Restrict delete
project_land_use_model_types_project_id_fkey
project_land_use_model_types.project_id
projects.id
Cascade on delete
reports_status_id_fkey
reports.status_id
report_statuses.id
Restrict delete
reports_organization_id_fkey
reports.organization_id
organizations.id
Restrict delete
reports_project_id_fkey
reports.project_id
projects.id
Null on delete
reports_locked_by_fkey
reports.locked_by
users.id
Restrict delete
reports_submitted_by_fkey
reports.submitted_by
users.id
Restrict delete
reports_modified_by_fkey
reports.modified_by
users.id
Restrict delete
organizations_organization_type_id_fkey
organizations.organization_type_id
organization_types.id
Restrict delete
organizations_created_by_fkey
organizations.created_by
users.id
Restrict delete
organizations_country_code_fkey
organizations.country_code
countries.code
Restrict delete
organizations_country_subdivision_code_fkey
organizations.country_subdivision_code
country_subdivisions.code
Restrict delete
organizations_modified_by_fkey
organizations.modified_by
users.id
Restrict delete
notifications_organization_id_fkey
notifications.organization_id
organizations.id
Cascade on delete
notifications_notification_type_id_fkey
notifications.notification_type_id
notification_types.id
Restrict delete
notifications_user_id_fkey
notifications.user_id
users.id
Restrict delete
organization_users_organization_id_fkey
organization_users.organization_id
organizations.id
Cascade on delete
organization_users_modified_by_fkey
organization_users.modified_by
users.id
Restrict delete
organization_users_created_by_fkey
organization_users.created_by
users.id
Restrict delete
organization_users_user_id_fkey
organization_users.user_id
users.id
Restrict delete
organization_users_role_id_fkey
organization_users.role_id
roles.id
Restrict delete
countries_region_id_fkey
countries.region_id
regions.id
Restrict delete
projects_country_code_fkey
projects.country_code
countries.code
Restrict delete
projects_created_by_fkey
projects.created_by
users.id
projects_organization_id_fkey
projects.organization_id
organizations.id
Restrict delete
projects_modified_by_fkey
projects.modified_by
users.id
facilities_modified_by_fkey
facilities.modified_by
users.id
Restrict delete
site_module_type_id_fkey
facilities.type_id
facility_types.id
Restrict delete
facilities_created_by_fkey
facilities.created_by
users.id
Restrict delete
facilities_connection_state_id_fkey
facilities.connection_state_id
facility_connection_states.id
Restrict delete
facilities_organization_id_fkey
facilities.organization_id
organizations.id
Cascade on delete
device_managers_facility_id_fkey
device_managers.facility_id
facilities.id
Restrict delete
device_managers_user_id_fkey
device_managers.user_id
users.id
Restrict delete
photos_modified_by_fkey
files.modified_by
users.id
Restrict delete
photos_user_id_fkey
files.created_by
users.id
Restrict delete
report_files_file_id_fkey
report_files.file_id
files.id
Cascade on delete
report_files_report_id_fkey
report_files.report_id
reports.id
Restrict delete
report_photos_report_id_fkey
report_photos.report_id
reports.id
Restrict delete
report_photos_photo_id_fkey
report_photos.file_id
files.id
Cascade on delete
country_subdivisions_country_code_fkey
country_subdivisions.country_code
countries.code
Restrict delete
user_global_roles_global_role_id_fkey
user_global_roles.global_role_id
global_roles.id
Cascade on delete
user_global_roles_user_id_fkey
user_global_roles.user_id
users.id
Cascade on delete
upload_problems_type_id_fkey
upload_problems.type_id
upload_problem_types.id
Restrict delete
upload_problems_upload_id_fkey
upload_problems.upload_id
uploads.id
Cascade on delete
internal_tags_modified_by_fkey
internal_tags.modified_by
users.id
Restrict delete
internal_tags_created_by_fkey
internal_tags.created_by
users.id
Restrict delete
uploads_facility_id_fkey
uploads.facility_id
facilities.id
Restrict delete
uploads_status_id_fkey
uploads.status_id
upload_statuses.id
Restrict delete
uploads_organization_id_fkey
uploads.organization_id
organizations.id
Restrict delete
uploads_type_id_fkey
uploads.type_id
upload_types.id
Restrict delete
uploads_created_by_fkey
uploads.created_by
users.id
Restrict delete
users_country_code_fkey
users.country_code
countries.code
Restrict delete
users_user_type_id_fkey
users.user_type_id
user_types.id
Restrict delete
organization_internal_tags_created_by_fkey
organization_internal_tags.created_by
users.id
Restrict delete
organization_internal_tags_organization_id_fkey
organization_internal_tags.organization_id
organizations.id
Cascade on delete
organization_internal_tags_internal_tag_id_fkey
organization_internal_tags.internal_tag_id
internal_tags.id
Cascade on delete

Check Constraints

Table Constraint Name Constraint
reports cannot_submit_while_locked (((locked_time IS NULL) OR (submitted_time IS NULL)))
reports locked_by_and_time_both_set ((((locked_by IS NULL) AND (locked_time IS NULL)) OR ((locked_by IS NOT NULL) AND (locked_time IS NOT NULL))))
reports quarter_in_range (((quarter >= 1) AND (quarter <= 4)))
reports status_reflects_locked ((((locked_by IS NULL) AND (status_id <> 3)) OR ((locked_by IS NOT NULL) AND (status_id = 3))))
reports status_reflects_submitted ((((submitted_by IS NULL) AND (status_id <> 4)) OR ((submitted_by IS NOT NULL) AND (status_id = 4))))
reports submitted_by_and_time_both_set ((((submitted_by IS NULL) AND (submitted_time IS NULL)) OR ((submitted_by IS NOT NULL) AND (submitted_time IS NOT NULL))))
organizations country_code_matches_subdivision (((country_subdivision_code IS NULL) OR (substr(country_subdivision_code, 1, 2) = country_code)))
organizations organizations_country_code_check ((country_code !~ similar_to_escape(' *'::text)))
organizations organizations_country_subdivision_code_check ((country_subdivision_code !~ similar_to_escape(' *'::text)))
organizations organizations_description_check ((description !~ similar_to_escape(' *'::text)))
organizations other_type_details_null_or_not_empty (((organization_type_details IS NULL) OR ((organization_type_details)::text <> ''::text)))
organizations other_type_details_only_for_other ((((organization_type_details IS NULL) AND (organization_type_id <> 6)) OR ((organization_type_details IS NOT NULL) AND (organization_type_id = 6))))
countries countries_code_caps ((code = upper(code)))
countries countries_code_length ((length(code) = 2))
facilities facilities_description_check ((description !~ similar_to_escape(' *'::text)))
device_managers device_managers_user_iff_facility ((((user_id IS NOT NULL) AND (facility_id IS NOT NULL)) OR ((user_id IS NULL) AND (facility_id IS NULL))))
files content_type_cannot_be_empty_string ((length(content_type) > 0))
files file_name_cannot_be_empty_string ((length(file_name) > 0))
country_subdivisions country_subdivisions_code_length (((length(code) >= 4) AND (length(code) <= 6)))
country_subdivisions country_subdivisions_code_matches_country ((substr(code, 1, 2) = country_code))
upload_problems upload_problems_field_check ((field !~ similar_to_escape(' *'::text)))
upload_problems upload_problems_message_check ((message !~ similar_to_escape(' *'::text)))
upload_problems upload_problems_value_check ((value !~ similar_to_escape(' *'::text)))
users users_auth_id_check ((auth_id !~ similar_to_escape(' *'::text)))
users users_first_name_check ((first_name !~ similar_to_escape(' *'::text)))
users users_last_name_check ((last_name !~ similar_to_escape(' *'::text)))