Constraints

41 Foreign Key Constraints

Constraint Name Child Column Parent Column Delete Rule
batch_photos_batch_id_fkey
batch_photos.batch_id
batches.id
Restrict delete
batch_photos_created_by_fkey
batch_photos.created_by
users.id
Restrict delete
batch_photos_deleted_by_fkey
batch_photos.deleted_by
users.id
Restrict delete
batch_photos_file_id_fkey
batch_photos.file_id
files.id
Null on delete
batch_withdrawals_destination_batch_id_fkey
batch_withdrawals.destination_batch_id
batches.id
Null on delete
batch_withdrawals_batch_id_fkey
batch_withdrawals.batch_id
batches.id
Cascade on delete
batch_withdrawals_withdrawal_id_fkey
batch_withdrawals.withdrawal_id
withdrawals.id
Cascade on delete
batch_quantity_history_withdrawal_id_fkey
batch_quantity_history.withdrawal_id
withdrawals.id
Cascade on delete
batch_quantity_history_created_by_fkey
batch_quantity_history.created_by
users.id
Restrict delete
batch_quantity_history_history_type_id_fkey
batch_quantity_history.history_type_id
batch_quantity_history_types.id
Restrict delete
batch_quantity_history_batch_id_fkey
batch_quantity_history.batch_id
batches.id
Cascade on delete
batch_sub_locations_batch_id_fkey
batch_sub_locations.batch_id
batches.id
Cascade on delete
batch_sub_locations_facility_id_batch_id_fkey
batch_sub_locations.facility_id
batch_sub_locations.batch_id
batches.facility_id
batches.id
Restrict delete
batch_sub_locations_facility_id_sub_location_id_fkey
batch_sub_locations.facility_id
batch_sub_locations.sub_location_id
sub_locations.facility_id
sub_locations.id
Restrict delete
batch_sub_locations_sub_location_id_fkey
batch_sub_locations.sub_location_id
sub_locations.id
Cascade on delete
batch_sub_locations_facility_id_fkey
batch_sub_locations.facility_id
facilities.id
Cascade on delete
withdrawals_undoes_withdrawal_id_fkey
withdrawals.undoes_withdrawal_id
withdrawals.id
Cascade on delete
withdrawals_facility_id_fkey
withdrawals.facility_id
facilities.id
Cascade on delete
withdrawals_created_by_fkey
withdrawals.created_by
users.id
Restrict delete
withdrawals_purpose_id_fkey
withdrawals.purpose_id
withdrawal_purposes.id
Restrict delete
withdrawals_destination_facility_id_fkey
withdrawals.destination_facility_id
facilities.id
Null on delete
withdrawals_modified_by_fkey
withdrawals.modified_by
users.id
Restrict delete
withdrawal_photos_photo_id_fkey
withdrawal_photos.file_id
files.id
Restrict delete
withdrawal_photos_withdrawal_id_fkey
withdrawal_photos.withdrawal_id
withdrawals.id
Restrict delete
batches_treatment_id_fkey
batches.treatment_id
seed_treatments.id
Restrict delete
batches_modified_by_fkey
batches.modified_by
users.id
Restrict delete
batches_substrate_id_fkey
batches.substrate_id
batch_substrates.id
Restrict delete
batches_created_by_fkey
batches.created_by
users.id
Restrict delete
batches_species_id_fkey
batches.species_id
species.id
Restrict delete
batches_facility_id_fkey
batches.facility_id
facilities.id
Cascade on delete
batches_accession_id_fkey
batches.accession_id
accessions.id
Null on delete
batches_project_id_fkey
batches.project_id
projects.id
Null on delete
batches_organization_id_fkey
batches.organization_id
organizations.id
Cascade on delete
batches_initial_batch_id_fkey
batches.initial_batch_id
batches.id
Null on delete
batch_details_history_substrate_id_fkey
batch_details_history.substrate_id
batch_substrates.id
Restrict delete
batch_details_history_batch_id_fkey
batch_details_history.batch_id
batches.id
Cascade on delete
batch_details_history_treatment_id_fkey
batch_details_history.treatment_id
seed_treatments.id
Restrict delete
batch_details_history_created_by_fkey
batch_details_history.created_by
users.id
Restrict delete
batch_details_history_project_id_fkey
batch_details_history.project_id
projects.id
Null on delete
batch_details_history_sub_locations_sub_location_id_fkey
batch_details_history_sub_locations.sub_location_id
sub_locations.id
Null on delete
batch_details_history_sub_locatio_batch_details_history_id_fkey
batch_details_history_sub_locations.batch_details_history_id
batch_details_history.id
Cascade on delete

Check Constraints

Table Constraint Name Constraint
batch_withdrawals quantity_signs_consistent ((((germinating_quantity_withdrawn <= 0) AND (not_ready_quantity_withdrawn <= 0) AND (ready_quantity_withdrawn <= 0)) OR ((germinating_quantity_withdrawn >= 0) AND (not_ready_quantity_withdrawn >= 0) AND (ready_quantity_withdrawn >= 0))))
batch_quantity_history batch_quantity_history_germinating_quantity_check ((germinating_quantity >= 0))
batch_quantity_history batch_quantity_history_not_ready_quantity_check ((not_ready_quantity >= 0))
batch_quantity_history batch_quantity_history_ready_quantity_check ((ready_quantity >= 0))
withdrawals undo_requires_withdrawal_id ((((purpose_id = 5) AND (undoes_withdrawal_id IS NOT NULL)) OR ((purpose_id <> 5) AND (undoes_withdrawal_id IS NULL))))
withdrawals withdrawals_destination_only_for_transfers (((destination_facility_id IS NULL) OR (purpose_id = 1)))
withdrawals withdrawals_notes_check ((notes !~ similar_to_escape(' *'::text)))
batches batches_germinating_quantity_check ((germinating_quantity >= 0))
batches batches_latest_observed_germinating_quantity_check ((latest_observed_germinating_quantity >= 0))
batches batches_latest_observed_not_ready_quantity_check ((latest_observed_not_ready_quantity >= 0))
batches batches_latest_observed_ready_quantity_check ((latest_observed_ready_quantity >= 0))
batches batches_not_ready_quantity_check ((not_ready_quantity >= 0))
batches batches_notes_check ((notes !~ similar_to_escape(' *'::text)))
batches batches_ready_quantity_check ((ready_quantity >= 0))
batches batches_version_check ((version > 0))