Skip to content

survey_version_question_branch_rules

Overview

Branch rules. A question can hold several. Rules are evaluated in order and the first one that holds is applied (first match wins).

Table Definition

Logical name Physical name Column Type PK Relation Unique Nullable Default Notes
Branch rule survey_version_question_branch_rules id uuid โ—ฏ gen_random_uuid() Re-assigned on every question update
question_id uuid survey_version_questions:id (cascade)
sort_order integer 0 Evaluation order; smaller values first
logical_operator branch_logical_operator AND / OR
destination_question_code varchar(100) โ—ฏ Destination question code; special codes also allowed
message text โ—ฏ Message shown when the condition holds
created_at timestamptz now()
updated_at timestamptz now()

Relations

  • question_id โ†’ survey_version_questions.id (onDelete: cascade)
  • Referenced by: survey_version_question_branch_conditions.branch_rule_id (cascade)

Indexes

  • Primary key (id)
  • UNIQUE INDEX: survey_version_question_branch_rules_question_order_idx (question_id, sort_order)

Special Destination Codes

destination_question_code is a varchar rather than an enum, so besides an ordinary question code it can hold:

Code Meaning
SO Survey complete
SC Section complete (jump to the head of the next section)
SX Screen out
The question's own code Exclusive setting: stay on the question and show message (cannot proceed)

Notes

  • What message is for: it can be used as a message for any branch, but when the destination is the question itself it acts as an "exclusive setting" that sends the respondent back. It corresponds to CS's logic_action.message
  • Expressing AND / OR: conditions within a rule are combined by logical_operator; nesting and mixing are not possible. CS has the same flat structure
  • Evaluation order: rules are evaluated in ascending sort_order and the first match is applied, matching CS's "higher rules win"
  • Destination scope: later non-intro questions within the same section, plus the special codes. Crossing sections is only possible via SC
  • Updating a question deletes and recreates the branch rules, so id is not stable
  • Setting an exclusive choice or "other" auto-generates the corresponding rules on the frontend