CREATE TABLE IF NOT EXISTS session_questions (
    id            TEXT PRIMARY KEY,
    session_id    TEXT NOT NULL REFERENCES sessions(id),
    question_id   TEXT NOT NULL REFERENCES questions(id),
    attempts_used INTEGER NOT NULL DEFAULT 0,
    hint_used     INTEGER NOT NULL DEFAULT 0,
    points_earned INTEGER NOT NULL DEFAULT 0,
    status        TEXT NOT NULL DEFAULT 'active',
    presented_at  TEXT NOT NULL DEFAULT (datetime('now')),
    answered_at   TEXT
);

CREATE UNIQUE INDEX IF NOT EXISTS idx_session_question
    ON session_questions(session_id, question_id);
