Files
english/supabase/schema.sql
2026-04-12 18:54:59 +07:00

34 lines
1.3 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- ============================================================
-- Schema: English Learning App (TOEIC Focus)
-- Run this FIRST before seed.sql
-- ============================================================
-- TOEIC questions (Part 17)
CREATE TABLE IF NOT EXISTS questions (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
part INT NOT NULL CHECK (part BETWEEN 1 AND 7),
type TEXT,
content TEXT NOT NULL,
options JSONB NOT NULL DEFAULT '[]', -- ["A. ...", "B. ...", "C. ...", "D. ..."]
answer TEXT NOT NULL, -- "A" | "B" | "C" | "D"
explanation TEXT,
audio_url TEXT, -- Part 14 (listening)
image_url TEXT, -- Part 1 (photos)
created_at TIMESTAMPTZ DEFAULT now()
);
-- TOEIC vocabulary (6 topics)
CREATE TABLE IF NOT EXISTS vocab (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
word TEXT NOT NULL,
phonetic TEXT,
meaning_vi TEXT NOT NULL,
topic TEXT NOT NULL CHECK (topic IN ('Business', 'Office', 'Travel', 'Finance', 'HR', 'Marketing')),
example TEXT,
created_at TIMESTAMPTZ DEFAULT now()
);
-- Indexes for common query patterns
CREATE INDEX IF NOT EXISTS idx_questions_part ON questions(part);
CREATE INDEX IF NOT EXISTS idx_vocab_topic ON vocab(topic);