-
Notifications
You must be signed in to change notification settings - Fork 1
/
query.sql
38 lines (36 loc) · 1020 Bytes
/
query.sql
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
CREATE TABLE "users" (
"fname" TEXT NOT NULL,
"lname" TEXT NOT NULL,
"email" TEXT NOT NULL,
"password" TEXT NOT NULL,
"gender" TEXT NOT NULL,
PRIMARY KEY("email")
);
CREATE TABLE "topic" (
"topic_id" INTEGER,
"title" VARCHAR(255) NOT NULL,
"details" TEXT NOT NULL,
"email" TEXT NOT NULL,
"created_at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY("email") REFERENCES "users"("email"),
PRIMARY KEY("topic_id" AUTOINCREMENT)
);
CREATE TABLE "tags" (
"tag_id" INTEGER,
"topic_id" INTEGER NOT NULL,
"tag" TEXT NOT NULL,
PRIMARY KEY("tag_id" AUTOINCREMENT),
FOREIGN KEY("topic_id") REFERENCES "topic"("topic_id")
);
CREATE TABLE "replies" (
"reply_id" INTEGER,
"topic_id" INTEGER,
"details" TEXT NOT NULL,
"email" TEXT NOT NULL,
"created_at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
"likes" INTEGER,
FOREIGN KEY("topic_id") REFERENCES "topic"("topic_id"),
PRIMARY KEY("reply_id" AUTOINCREMENT)
);