mebook_questions
Overview
The mebook_questions table stores the individual questions within each MeBook section. Questions have various types (multiple_choice, scale, text, etc.) and can optionally map to app preferences via the maps_to_preference field.
Schema
-- From 20260130_mebook_system.sql
CREATE TABLE mebook_questions (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
section_id UUID NOT NULL REFERENCES mebook_sections(id) ON DELETE CASCADE,
key TEXT UNIQUE NOT NULL,
question_text TEXT NOT NULL,
question_type TEXT NOT NULL CHECK (question_type IN (
'multiple_choice', 'scale', 'text', 'toggle', 'ranking', 'color_picker'
)),
description TEXT,
maps_to_preference TEXT,
sort_order INTEGER DEFAULT 0,
is_required BOOLEAN DEFAULT FALSE,
is_active BOOLEAN DEFAULT TRUE,
metadata JSONB DEFAULT '{}',
created_at TIMESTAMPTZ DEFAULT NOW()
);
Columns
| Column | Type | Nullable | Default | Description |
|---|---|---|---|---|
id | uuid | No | gen_random_uuid() | Primary key |
section_id | uuid | No | -- | Parent section |
key | text | No | -- | Unique question key |
question_text | text | No | -- | The question text shown to users |
question_type | text | No | -- | Input type: multiple_choice, scale, text, toggle, ranking, color_picker |
description | text | Yes | -- | Additional context for the question |
maps_to_preference | text | Yes | -- | App preference key this maps to |
sort_order | integer | No | 0 | Display order within section |
is_required | boolean | No | FALSE | Whether answer is required |
is_active | boolean | No | TRUE | Whether question is available |
metadata | jsonb | No | '{}' | Additional question configuration |
created_at | timestamptz | No | NOW() | Seed timestamp |
RLS Policies
-- SELECT: All authenticated users can read questions
CREATE POLICY "Questions are readable by all"
ON mebook_questions FOR SELECT
USING (true);
Related
- mebook_sections -- Parent section
- mebook_question_options -- Options for multiple choice questions
- mebook_responses -- User answers
Last updated: 2026-02-07