-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sql
More file actions
70 lines (56 loc) · 1.3 KB
/
init.sql
File metadata and controls
70 lines (56 loc) · 1.3 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
DROP TABLE IF EXISTS "user";
CREATE TABLE "user" (
"id" serial NOT NULL,
"email" varchar(255) NULL,
"password" varchar(255) NULL,
"name" varchar(255) NULL
);
DROP TABLE IF EXISTS "subject";
CREATE TABLE "subject" (
"id" serial NOT NULL,
"user_id" integer NOT NULL,
"title" varchar(255) NULL,
"text" text NULL,
"progress" integer DEFAULT 0
);
DROP TABLE IF EXISTS "chapter";
CREATE TABLE "chapter" (
"id" serial NOT NULL,
"subject_id" serial NOT NULL,
"title" varchar(255) NULL,
"content" text NULL
);
DROP TABLE IF EXISTS "problem";
CREATE TABLE "problem" (
"id" serial NOT NULL,
"quiz_id" integer NOT NULL,
"title" text NULL,
"question" text NULL,
"feedback" text NULL,
"solution" text NULL,
"user_answer" text NULL,
"is_correct" boolean NULL
);
DROP TABLE IF EXISTS "quiz";
CREATE TABLE "quiz" (
"id" serial NOT NULL,
"chapter_id" integer NOT NULL,
"total_count" integer NULL,
"submit_count" integer NULL,
"correct_count" integer NULL
);
ALTER TABLE "user" ADD CONSTRAINT "PK_USER" PRIMARY KEY (
"id"
);
ALTER TABLE "subject" ADD CONSTRAINT "PK_SUBJECT" PRIMARY KEY (
"id"
);
ALTER TABLE "chapter" ADD CONSTRAINT "PK_CHAPTER" PRIMARY KEY (
"id"
);
ALTER TABLE "problem" ADD CONSTRAINT "PK_PROBLEM" PRIMARY KEY (
"id"
);
ALTER TABLE "quiz" ADD CONSTRAINT "PK_QUIZ" PRIMARY KEY (
"id"
);