-
Notifications
You must be signed in to change notification settings - Fork 1
Klamm Data Model
Spencer Rose edited this page Jul 17, 2025
·
13 revisions
The revised Klamm data model organizes web form elements using a central FormElements table for common attributes and a polymorphic design to implement different element types (like text input or button). Each FormElements element dynamically links to its specific type via elementable_id and elementable_type columns, storing unique properties in dedicated tables such as TextareaInputFormElements. Furthermore, a self-referencing parent_id within FormElements enables a flexible hierarchical structure, allowing specific elements to act as containers for other elements.
erDiagram
%% Main entities with vertical layout
Forms ||--o{ FormVersions : "has many"
%% FormVersions relationships
FormVersions ||--o{ FormElements : "has many"
FormVersions ||--o{ FormStylesheets : "applied to"
FormVersions ||--o{ FormScripts : "has many"
FormStylesheets ||--o{ FormVersions : "applied to"
FormScripts ||--o{ FormVersions : "applied to"
FormVersions ||--o{ FormDeployments : "has many"
%% FormElement (using labels to indicate inheritance)
FormElements ||--|o FormFieldDataBindings : "has one"
FormElements ||--|o FormElements : "has one parent"
%% Models for FormElements Types
TextInputFormElements ||--o{ FormElements : "has one"
CheckboxInputFormElements ||--o{ FormElements : "has one"
SelectInputFormElements ||--o{ FormElements : "has one"
RadioInputFormElements ||--o{ FormElements : "has one"
TextareaInputFormElements ||--o{ FormElements : "has one"
NumberInputFormElements ||--o{ FormElements : "has one"
DateSelectInputFormElements ||--o{ FormElements : "has one"
ButtonInputFormElements ||--o{ FormElements : "has one"
ContainerFormElements ||--o{ FormElements : "has one"
HTMLFormElements ||--o{ FormElements : "has one"
%% Sub-FormElements
SelectInputFormElements ||--o{ SelectOptionFormElements : "has many"
%% Form Field Validators
TextInputFormElements ||--o{ FormFieldValidators : "has many"
CheckboxInputFormElements ||--o{ FormFieldValidators : "has many"
NumberInputFormElements ||--o{ FormFieldValidators : "has many"
TextareaInputFormElements ||--o{ FormFieldValidators : "has many"
SelectInputFormElements ||--o{ FormFieldValidators : "has many"
RadioInputFormElements ||--o{ FormFieldValidators : "has many"
DateSelectInputFormElements ||--o{ FormFieldValidators : "has many"
%% Entity definitions
Forms {
int id PK
int forms_id
int parent_form_elements_id FK
string form_title
int ministry_id FK
string description
string notes
int data_bindings_id FK
int form_frequencies_id FK
int form_reaches_id FK
string print_reason
string retention_needs
boolean icm_non_interactive
string workbench_footer_fragment_path
string dcv_material_number
string orbeon_functions
boolean icm_generated
}
FormVersions {
int id PK
int form_id FK
string uuid
int version_number
string status "draft|approved|final"
int form_developer_id FK
}
FormDeployments {
int id PK
int form_version_id FK
string environment "test|dev|prod"
datetime deployed_at
}
FormFieldDataBindings {
int id PK
string name
string description
string data_sources_id FK
string data_binding_path
string data_binding_type
}
FormStylesheets {
int id PK
int form_version_id FK
string filepath
string name
string type "web|pdf"
string description
}
FormScripts {
int id PK
int form_version_id FK
string filepath
string name
string type "web|pdf"
string description
}
FormFieldValidators {
int id PK
string name
string regex
string description
}
FormElements {
int id PK
uuid token
string name
int form_versions_id FK
int parent_id FK "Nullable FK to FormElements.id (for hierarchical structure)"
int elementable_id FK "ID of element type"
string elementable_type "Class name of element type (e.g., 'ContainerFormElements')"
string help_text
string description
boolean is_repeatable
string repeater_item_label
boolean is_resetable
boolean visible_web
boolean visible_pdf
boolean is_template
}
TextInputFormElements {
int id PK
string placeholder_text
string label
boolean visible_label
string mask
int maxlength
int minlength
}
CheckboxInputFormElements {
int id PK
string label
boolean visible_label
}
SelectInputFormElements {
int id PK
string label
boolean visible_label
}
SelectOptionFormElements {
int id PK
int form_element_select_inputs_id FK
string label
int order
string description
}
RadioInputFormElements {
int id PK
string label
boolean visible_label
string[] options
string default_value
}
TextareaInputFormElements {
int id PK
string name
string placeholder_text
string label
boolean visible_label
int rows
int cols
int maxlength
int minlength
}
NumberInputFormElements {
int id PK
string placeholder_text
string label
boolean visible_label
int min
int max
int step
int default_value
}
DateSelectInputFormElements {
int id PK
string placeholder_text
string label
boolean visible_label
string repeater_item_label
date min_date
date max_date
date default_date
string date_format
boolean include_time
}
ButtonInputFormElements {
int id PK
string label
string button_type "submit|reset|button"
}
ContainerFormElements {
int id PK
string container_type "page|fieldset|section"
boolean collapsible
boolean collapsed_by_default
}
HTMLFormElements {
int id PK
string name
string html_content "raw HTML to embed"
string repeater_item_label
}
%% Relationships
%% Self-referencing relationship for parent/child
FormElements o|--o{ FormElements : "can be parent/child of"
%% FormElements morphs to one of the specific types (Laravel Eloquent)
%% We represent it by showing the FK/type columns and multiple optional relationships.
FormElements ||--o| ContainerFormElements : "morphs to (if Container)"
FormElements ||--o| TextareaInputFormElements : "morphs to (if Textarea)"
FormElements ||--o| NumberInputFormElements : "morphs to (if Number)"
FormElements ||--o| DateSelectInputFormElements : "morphs to (if DateSelect)"
FormElements ||--o| ButtonInputFormElements : "morphs to (if Button)"
FormElements ||--o| TextInputFormElements : "morphs to (if Text)"
FormElements ||--o| HTMLFormElements : "morphs to (if HTML)"