11 KiB
Database Entities Documentation
This document describes the core entities in the USDA Vision database schema, focusing on entity-specific attributes (excluding generic fields like id, created_at, updated_at, created_by).
Entity Relationships Overview
Experiment Phase (Template)
↓
Experiment
↓
Experiment Repetition
↓
Experiment Phase Execution (Soaking, Airdrying, Cracking, Shelling)
1. Experiment Phase
Table: experiment_phases
Purpose: Defines a template/blueprint for experiments that specifies which processing phases are included and their configuration.
Attributes
-
name (TEXT, UNIQUE, NOT NULL)
- Unique name identifying the experiment phase template
- Example: "Phase 2 - Standard Processing"
-
description (TEXT, nullable)
- Optional description providing details about the experiment phase
-
has_soaking (BOOLEAN, NOT NULL, DEFAULT false)
- Indicates whether soaking phase is included in experiments using this template
-
has_airdrying (BOOLEAN, NOT NULL, DEFAULT false)
- Indicates whether airdrying phase is included in experiments using this template
-
has_cracking (BOOLEAN, NOT NULL, DEFAULT false)
- Indicates whether cracking phase is included in experiments using this template
-
has_shelling (BOOLEAN, NOT NULL, DEFAULT false)
- Indicates whether shelling phase is included in experiments using this template
-
cracking_machine_type_id (UUID, nullable)
- References the machine type to be used for cracking (required if
has_crackingis true) - Links to
machine_typestable
- References the machine type to be used for cracking (required if
Constraints
- At least one phase (soaking, airdrying, cracking, or shelling) must be enabled
- If
has_crackingis true,cracking_machine_type_idmust be provided
2. Experiment
Table: experiments
Purpose: Defines an experiment blueprint that specifies the parameters and requirements for conducting pecan processing experiments.
Attributes
-
experiment_number (INTEGER, NOT NULL)
- Unique number identifying the experiment
- Combined with
phase_idmust be unique
-
reps_required (INTEGER, NOT NULL, CHECK > 0)
- Number of repetitions required for this experiment
- Must be greater than zero
-
weight_per_repetition_lbs (DOUBLE PRECISION, NOT NULL, DEFAULT 5.0, CHECK > 0)
- Weight in pounds required for each repetition of the experiment
-
results_status (TEXT, NOT NULL, DEFAULT 'valid', CHECK IN ('valid', 'invalid'))
- Status indicating whether the experiment results are considered valid or invalid
-
completion_status (BOOLEAN, NOT NULL, DEFAULT false)
- Indicates whether the experiment has been completed
-
phase_id (UUID, NOT NULL)
- References the experiment phase template this experiment belongs to
- Links to
experiment_phasestable
Constraints
- Combination of
experiment_numberandphase_idmust be unique
3. Experiment Repetition
Table: experiment_repetitions
Purpose: Represents a single execution instance of an experiment that can be scheduled and tracked.
Attributes
-
experiment_id (UUID, NOT NULL)
- References the parent experiment blueprint
- Links to
experimentstable
-
repetition_number (INTEGER, NOT NULL, CHECK > 0)
- Sequential number identifying this repetition within the experiment
- Must be unique per experiment
-
scheduled_date (TIMESTAMP WITH TIME ZONE, nullable)
- Date and time when the repetition is scheduled to be executed
-
status (TEXT, NOT NULL, DEFAULT 'pending', CHECK IN ('pending', 'in_progress', 'completed', 'cancelled'))
- Current status of the repetition execution
- Values:
pending,in_progress,completed,cancelled
Constraints
- Combination of
experiment_idandrepetition_numbermust be unique
4. Experiment Phase Executions
Table: experiment_phase_executions
Purpose: Unified table storing execution data for all phase types (soaking, airdrying, cracking, shelling) associated with experiment repetitions.
Common Attributes (All Phase Types)
-
repetition_id (UUID, NOT NULL)
- References the experiment repetition this phase execution belongs to
- Links to
experiment_repetitionstable
-
phase_type (TEXT, NOT NULL, CHECK IN ('soaking', 'airdrying', 'cracking', 'shelling'))
- Type of phase being executed
- Must be one of:
soaking,airdrying,cracking,shelling
-
scheduled_start_time (TIMESTAMP WITH TIME ZONE, NOT NULL)
- Planned start time for the phase execution
-
scheduled_end_time (TIMESTAMP WITH TIME ZONE, nullable)
- Planned end time for the phase execution
- Automatically calculated for soaking and airdrying based on duration
-
actual_start_time (TIMESTAMP WITH TIME ZONE, nullable)
- Actual time when the phase execution started
-
actual_end_time (TIMESTAMP WITH TIME ZONE, nullable)
- Actual time when the phase execution ended
-
status (TEXT, NOT NULL, DEFAULT 'pending', CHECK IN ('pending', 'scheduled', 'in_progress', 'completed', 'cancelled'))
- Current status of the phase execution
Phase-Specific Concepts: Independent & Dependent Variables
Note: This section describes the conceptual variables for each phase (what we measure or control), not necessarily the current physical columns in the database. Some of these variables will be added to the schema in future migrations.
Soaking Phase
-
Independent variables (IV)
- Pre-soaking shell moisture percentage
- Moisture percentage of the shell before soaking.
- Pre-soaking kernel moisture percentage
- Moisture percentage of the kernel before soaking.
- Average pecan diameter (inches)
- Average diameter of pecans in the batch, measured in inches.
- Batch weight
- Total weight of the batch being soaked.
- Soaking duration (minutes)
- Duration of the soaking process in minutes (currently represented as
soaking_duration_minutes).
- Duration of the soaking process in minutes (currently represented as
- Pre-soaking shell moisture percentage
-
Dependent variables (DV)
- Post-soaking shell moisture percentage
- Moisture percentage of the shell after soaking.
- Post-soaking kernel moisture percentage
- Moisture percentage of the kernel after soaking.
- Post-soaking shell moisture percentage
Airdrying Phase
-
Independent variables (IV)
- Airdrying duration (minutes)
- Duration of the airdrying process in minutes (currently represented as
duration_minutes).
- Duration of the airdrying process in minutes (currently represented as
- Airdrying duration (minutes)
-
Dependent variables (DV)
- (TBD — moisture/other measurements after airdrying can be added here when finalized.)
Cracking Phase
-
Independent variables (IV)
- Cracking machine type
- The type of cracking machine used (linked via
machine_type_idandexperiment_phases.cracking_machine_type_id).
- The type of cracking machine used (linked via
- Cracking machine type
-
Dependent variables (DV)
- None defined yet for cracking.
Business/analysis metrics for cracking can be added later (e.g., crack quality, breakage rates).
- None defined yet for cracking.
Shelling Phase
-
Independent variables (IV)
- Shelling machine configuration parameters (not yet present in the DB schema)
- Ring gap (inches)
- Radial gap setting of the shelling ring (e.g.,
0.34inches).
- Radial gap setting of the shelling ring (e.g.,
- Paddle RPM
- Rotational speed of the paddles (integer RPM value).
- Third machine parameter (TBD)
- The shelling machine expects a third configuration parameter that will be defined and added to the schema later.
- Ring gap (inches)
- Shelling machine configuration parameters (not yet present in the DB schema)
-
Dependent variables (DV)
- Half-yield ratio (percentage)
- Percentage of the shelled product that is composed of half kernels, relative to total yield.
- Half-yield ratio (percentage)
Constraints
- Combination of
repetition_idandphase_typemust be unique (one execution per phase type per repetition)
Notes
- Phase executions are automatically created when an experiment repetition is created, based on the experiment phase template configuration
- Sequential phases (soaking → airdrying → cracking → shelling) automatically calculate their
scheduled_start_timebased on the previous phase'sscheduled_end_time - For soaking and airdrying phases,
scheduled_end_timeis automatically calculated fromscheduled_start_time+ duration
5. Machine Types
Table: machine_types
Purpose: Defines the types of machines available for cracking operations.
Attributes
-
name (TEXT, UNIQUE, NOT NULL)
- Unique name identifying the machine type
- Example: "JC Cracker", "Meyer Cracker"
-
description (TEXT, nullable)
- Optional description of the machine type
Related Tables
Machine types are referenced by:
experiment_phases.cracking_machine_type_id- Defines which machine type to use for cracking in an experiment phase templateexperiment_phase_executions.machine_type_id- Specifies which machine was used for a specific cracking execution
6. Cracker Parameters (Machine-Specific)
JC Cracker Parameters
Table: jc_cracker_parameters
Purpose: Stores parameters specific to JC Cracker machines.
Attributes
-
plate_contact_frequency_hz (DOUBLE PRECISION, NOT NULL, CHECK > 0)
- Frequency of plate contact in Hertz
-
throughput_rate_pecans_sec (DOUBLE PRECISION, NOT NULL, CHECK > 0)
- Rate of pecan processing in pecans per second
-
crush_amount_in (DOUBLE PRECISION, NOT NULL, CHECK >= 0)
- Amount of crushing in inches
-
entry_exit_height_diff_in (DOUBLE PRECISION, NOT NULL)
- Difference in height between entry and exit points in inches
Meyer Cracker Parameters
Table: meyer_cracker_parameters
Purpose: Stores parameters specific to Meyer Cracker machines.
Attributes
-
motor_speed_hz (DOUBLE PRECISION, NOT NULL, CHECK > 0)
- Motor speed in Hertz
-
jig_displacement_inches (DOUBLE PRECISION, NOT NULL)
- Jig displacement in inches
-
spring_stiffness_nm (DOUBLE PRECISION, NOT NULL, CHECK > 0)
- Spring stiffness in Newton-meters
Summary of Entity Relationships
- Experiment Phase → Defines which phases are included and machine type for cracking
- Experiment → Belongs to an Experiment Phase, defines repetition requirements and weight per repetition
- Experiment Repetition → Instance of an Experiment, can be scheduled and tracked
- Experiment Phase Execution → Execution record for each phase (soaking, airdrying, cracking, shelling) within a repetition
- Machine Types → Defines available cracking machines
- Cracker Parameters → Machine-specific operational parameters (JC or Meyer)
Key Relationships
- One Experiment Phase can have many Experiments
- One Experiment can have many Experiment Repetitions
- One Experiment Repetition can have multiple Phase Executions (one per phase type)
- Phase Executions are automatically created based on the Experiment Phase template configuration
- Cracking Phase Executions reference a Machine Type
- Machine Types can have associated Cracker Parameters (JC or Meyer specific)