batch_withdrawals

0 rows


Description

Number of seedlings withdrawn from each originating batch as part of a withdrawal.

Columns

Column Type Size Nulls Auto Default Children Parents Comments
batch_id int8 19 null
batches.id batch_withdrawals_batch_id_fkeyC

The batch from which the seedlings were withdrawn, also referred to as the originating batch.

withdrawal_id int8 19 null
withdrawals.id batch_withdrawals_withdrawal_id_fkeyC

The withdrawal that removed seedlings from this batch. A withdrawal can come from multiple batches, in which case there will be more than one batch_withdrawals row with the same withdrawal ID.

germinating_quantity_withdrawn int4 10 null

Number of germinating seedlings that were withdrawn from this batch. This is not necessarily the total number of seedlings in the withdrawal as a whole since a withdrawal can come from multiple batches.

not_ready_quantity_withdrawn int4 10 null

Number of not-ready-for-planting seedlings that were withdrawn from this batch. This is not necessarily the total number of seedlings in the withdrawal as a whole since a withdrawal can come from multiple batches.

ready_quantity_withdrawn int4 10 null

Number of ready-for-planting seedlings that were withdrawn from this batch. This is not necessarily the total number of seedlings in the withdrawal as a whole since a withdrawal can come from multiple batches.

destination_batch_id int8 19 null
batches.id batch_withdrawals_destination_batch_id_fkeyN

If the withdrawal was a nursery transfer, the batch that was created as a result. A withdrawal can have more than one originating batch; if they are of the same species, only one destination batch will be created and there will be multiple rows with the same destination_batch_id. May be null if the batch was subsequently deleted.

Indexes

Constraint Name Type Sort Column(s)
batch_withdrawals_pkey Primary key Asc/Asc batch_id + withdrawal_id
batch_withdrawals_destination_batch_id_idx Performance Asc destination_batch_id
batch_withdrawals_withdrawal_id_idx Performance Asc withdrawal_id

Check Constraints

Constraint Name Constraint
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))))

Relationships