survey_version_questions
Overview
Snapshots of the questions belonging to a section, including type-specific attributes (selection limits, matrix single-select, sub-questions).
Table Definition
| Logical name | Physical name | Column | Type | PK | Relation | Unique | Nullable | Default | Notes |
|---|---|---|---|---|---|---|---|---|---|
| Question | survey_version_questions | id | uuid | โฏ | gen_random_uuid() | Re-assigned when the version changes | |||
| section_id | uuid | survey_version_sections:id (cascade) | |||||||
| stable_question_id | uuid | gen_random_uuid() | Stable ID, carried over when a version is copied | ||||||
| question_code | varchar(100) | Question code. The reference key for branch conditions and destinations. Unique within a survey | |||||||
| question_type | question_type | single / multi / free_text / matrix / intro / pulldown | |||||||
| prompt_text | text | Prompt text | |||||||
| note_text | text | โฏ | Note | ||||||
| is_required | boolean | false | Whether an answer is mandatory | ||||||
| is_linked_to_previous | boolean | false | Whether to show on the same page as the previous question | ||||||
| is_single_matrix_select | boolean | โฏ | Matrix single-select. null for non-TM questions | ||||||
| min_selections | integer | โฏ | Minimum selections for MA. null = no limit | ||||||
| max_selections | integer | โฏ | Maximum selections for MA. null = no limit | ||||||
| sub_questions | jsonb | โฏ | Sub-question labels. The order maps to sub_question_index on choices | ||||||
| sort_order | integer | Position within the section | |||||||
| created_at | timestamptz | now() | |||||||
| updated_at | timestamptz | now() |
Relations
- section_id โ survey_version_sections.id (onDelete: cascade)
- Referenced by:
survey_version_question_options.question_id(cascade) - Referenced by:
survey_version_question_branch_rules.question_id(cascade) - Referenced by:
survey_version_question_visibility_rules.question_id(cascade)
Indexes
- Primary key (id)
- UNIQUE INDEX: survey_version_questions_section_order_idx (section_id, sort_order)
Notes
- The question code is the reference key: branch condition sources (
source_question_code) and destinations (destination_question_code) point at thisquestion_code. Duplicating a question assigns a new code and re-points self-references at it - Codes are renumbered when the order changes: after reordering, deleting, duplicating, or importing, every
question_codein the survey is renumbered into a clean sequence (Tforintro,Qfor the rest). Branch and visibility reference codes are re-pointed in the same transaction (Renumber the Question Codes) - Sub-question structure:
sub_questionsholds only labels; each sub-question's choices live in survey_version_question_options with asub_question_index. This applies to SA / MA / pulldown - Selection limits: MA only. They are discarded when the question type changes away from
multi. With sub-questions, the same limit applies to each - The
introrestriction: intro steps have no answer field and cannot be used as a branch condition source (the API returns 400 if one is specified) - Choices, matrix rows and columns, and FA input fields are deleted and recreated on every question update