survey_version_question_options
概要
設問の選択肢を格納するテーブル。通常の選択肢・マトリクスの行/列・FA の入力欄・プルダウンの欄をすべてこの 1 テーブルで扱う。どれとして解釈するかは親設問の question_type と axis / sub_question_index で決まる。
テーブル定義
| 論理名 |
物理名 |
カラム名 |
データ型 |
主キー |
リレーション |
ユニーク |
NULL許可 |
デフォルト値 |
備考 |
| 選択肢 |
survey_version_question_options |
id |
uuid |
◯ |
|
|
|
gen_random_uuid() |
設問の更新のたびに新しい値が振られる |
|
|
question_id |
uuid |
|
survey_version_questions:id (cascade) |
|
|
|
|
|
|
label |
varchar(255) |
|
|
|
|
|
選択肢ラベル。分岐条件の比較値として参照される |
|
|
sort_order |
integer |
|
|
|
|
|
設問内での並び順 |
|
|
is_exclusive |
boolean |
|
|
|
|
false |
排他選択肢 |
|
|
allow_other_input |
boolean |
|
|
|
|
false |
「その他」の自由入力欄を表示する |
|
|
is_not_applicable |
boolean |
|
|
|
|
false |
「当てはまるものはない」の特殊選択肢 |
|
|
axis |
question_option_axis |
|
|
|
◯ |
|
row / column。マトリクスのみ |
|
|
placeholder |
text |
|
|
|
◯ |
|
入力欄のプレースホルダ。FA のみ |
|
|
field_is_required |
boolean |
|
|
|
◯ |
|
欄ごとの必須/任意。FA のみ |
|
|
sub_question_index |
integer |
|
|
|
◯ |
|
何番目のサブ設問に属す選択肢か。フラット設問 / TM / FA では null |
|
|
created_at |
timestamptz |
|
|
|
|
now() |
|
|
|
updated_at |
timestamptz |
|
|
|
|
now() |
|
リレーション
- question_id → survey_version_questions.id (onDelete: cascade)
インデックス
- 主キー (id)
- UNIQUE INDEX: survey_version_question_options_question_order_idx (question_id, sort_order)
設問タイプ別の解釈
| 親設問の question_type |
行の意味 |
使うカラム |
single / multi |
選択肢 |
label / is_exclusive / allow_other_input / is_not_applicable / sub_question_index |
matrix |
行または列 |
上記 + axis(row = 質問対象、column = 評価尺度) |
free_text |
入力欄 |
label(項目名称)/ placeholder / field_is_required |
pulldown |
欄の選択肢 |
label / sub_question_index(欄の位置) |
intro |
使用しない |
— |
注記
id は安定しない: 設問を更新すると既存行が削除されて作り直されるため、id は更新のたびに変わる。分岐条件・表示ロジックが選択肢を ラベル文字列 で参照しているのはこのため
- 1 テーブルに集約している理由: 選択肢・マトリクスの行列・FA 欄はいずれも「順序を持つラベルの並び」であり、排他や「その他」などの属性も共通するため。テーブルを分けずに親設問のタイプで解釈を切り替えている
- CS へ投入する際は、選択系では
answer_item、マトリクスでは行が answer_item / 列が sub_item、FA では欄が answer_item にマップされる