-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjohn_trial.sql
More file actions
76 lines (70 loc) · 2.6 KB
/
john_trial.sql
File metadata and controls
76 lines (70 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
CREATE TABLE users (
user_id UUID NOT NULL PRIMARY KEY,
email VARCHAR(255) NOT NULL UNIQUE,
name VARCHAR(100) NOT NULL,
role ENUM('USER', 'ADMIN') NOT NULL DEFAULT 'USER',
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE journals (
journal_id UUID PRIMARY KEY,
user_id UUID NOT NULL,
content TEXT NOT NULL,
status ENUM('DRAFT', 'SUBMITTED') NOT NULL DEFAULT 'DRAFT',
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
submitted_at TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(user_id) ON DELETE CASCADE
);
CREATE TABLE feedback_templates (
template_id UUID PRIMARY KEY,
error_type VARCHAR(50) NOT NULL, -- GRAMMAR, VOCABULARY, STYLE
category VARCHAR(50), -- TENSE, ARTICLE, etc.
issue_text TEXT NOT NULL,
suggestion TEXT NOT NULL,
explanation TEXT
);
CREATE TABLE feedbacks (
feedback_id UUID PRIMARY KEY,
journal_id UUID NOT NULL,
template_id UUID NOT NULL,
original_text TEXT NOT NULL,
suggested_text TEXT NOT NULL,
explanation TEXT,
user_notes TEXT,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (journal_id) REFERENCES journals(journal_id) ON DELETE CASCADE,
FOREIGN KEY (template_id) REFERENCES feedback_templates(template_id) ON DELETE SET NULL
);
CREATE TABLE flashcards (
flashcard_id UUID NOT NULL PRIMARY KEY,
user_id UUID NOT NULL,
source_feedback_id UUID NULL,
word VARCHAR(255) NOT NULL,
definition TEXT,
example TEXT,
level ENUM('BEGINNER', 'INTERMEDIATE', 'ADVANCED'),
created_from ENUM('MISTAKE', 'NEW_WORD', 'MANUAL') NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(user_id),
FOREIGN KEY (source_feedback_id) REFERENCES feedbacks(feedback_id) ON DELETE SET NULL
);
CREATE TABLE progress_snapshots (
snapshot_id UUID NOT NULL PRIMARY KEY,
user_id UUID NOT NULL,
taken_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
journal_count INT NOT NULL DEFAULT 0,
unique_word_count INT NOT NULL DEFAULT 0,
error_rate FLOAT NOT NULL DEFAULT 0,
FOREIGN KEY (user_id) REFERENCES users(user_id) ON DELETE CASCADE
);
CREATE TABLE llm_interaction_logs (
log_id UUID NOT NULL PRIMARY KEY,
user_id UUID NOT NULL,
journal_id UUID NULL,
request_payload JSON NOT NULL,
response_payload JSON,
latency_ms INT,
cost_usd DECIMAL(10, 6),
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(user_id),
FOREIGN KEY (journal_id) REFERENCES journals(journal_id)
);