CREATE TABLE quiz_results (
    id           INTEGER PRIMARY KEY AUTOINCREMENT,
    user_id      INTEGER NOT NULL REFERENCES users(id),
    entity_type  TEXT NOT NULL,
    entity_id    INTEGER NOT NULL,
    score        INTEGER NOT NULL,
    total        INTEGER NOT NULL,
    answers      TEXT NOT NULL,
    taken_at     DATETIME DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX idx_quiz_r_user   ON quiz_results(user_id);
