mebook_responses
Overview
The mebook_responses table stores user answers to MeBook questions. Each response records the answer value and optionally the selected option. When a question maps to an app preference, saving a response can trigger preference updates via helper functions.
Relevant Invariants
- Invariant #16: "AI Never Observes Individuals" -- MeBook data is used for self-reflection, not profiling
- Invariant #14: "Privacy Is Infrastructure" -- Responses are private to the user
Schema
-- From 20260130_mebook_system.sql
CREATE TABLE mebook_responses (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID NOT NULL REFERENCES auth.users(id) ON DELETE CASCADE,
question_id UUID NOT NULL REFERENCES mebook_questions(id) ON DELETE CASCADE,
response_value TEXT,
selected_option_id UUID REFERENCES mebook_question_options(id),
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW(),
UNIQUE(user_id, question_id)
);
Columns
| Column | Type | Nullable | Default | Description |
|---|---|---|---|---|
id | uuid | No | gen_random_uuid() | Primary key |
user_id | uuid | No | -- | Responding user |
question_id | uuid | No | -- | Question being answered |
response_value | text | Yes | -- | Text/scale answer value |
selected_option_id | uuid | Yes | -- | Selected option for multiple choice |
created_at | timestamptz | No | NOW() | First response timestamp |
updated_at | timestamptz | No | NOW() | Last update timestamp |
RLS Policies
-- SELECT: Users can only read their own responses
CREATE POLICY "Users can view own responses"
ON mebook_responses FOR SELECT
USING (auth.uid() = user_id);
-- INSERT/UPDATE: Users can manage their own responses
CREATE POLICY "Users can upsert own responses"
ON mebook_responses FOR ALL
USING (auth.uid() = user_id);
Related
- mebook_questions -- Question being answered
- mebook_question_options -- Selected option
- profiles -- Responding user
Last updated: 2026-02-07