-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathschema.sql
73 lines (57 loc) Β· 1.47 KB
/
schema.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
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
CREATE TABLE "users" (
"username" varchar,
"email" varchar,
"fullName" varchar,
"tags" varchar,
"uid" integer primary key,
);
CREATE TABLE "guilds" (
"name" varchar,
"members" varchar,
"uid" integer,
"tags" varchar,
"gid" integer
);
CREATE TABLE "posts" (
"title" varchar,
"tags" varchar,
"uid" integer,
"data" text,
"hearts" integer
"pid" integer primary key
);
CREATE TABLE "gid" (
"mid" integer,
"timestamp" timestamp,
"text" varchar,
"uid" integer
);
CREATE TABLE "thread" (
"tid" integer,
"uid" integer,
"title" varchar,
"tags" varchar
);
CREATE TABLE "answers" (
"fid" integer,
"tid" integer,
"upvotes" integer
);
CREATE TABLE "connections" (
"fid" integer,
"tid" integer,
"connected" boolean
);
CREATE TABLE "invites" (
"gid" integer,
"uid" integer
);
ALTER TABLE "posts" ADD FOREIGN KEY ("uid") REFERENCES "users" ("uid");
ALTER TABLE "thread" ADD FOREIGN KEY ("uid") REFERENCES "users" ("uid");
ALTER TABLE "thread" ADD FOREIGN KEY ("tid") REFERENCES "answers" ("tid");
ALTER TABLE "users" ADD FOREIGN KEY ("uid") REFERENCES "gid" ("uid");
ALTER TABLE "users" ADD FOREIGN KEY ("uid") REFERENCES "guilds" ("uid");
ALTER TABLE "invites" ADD FOREIGN KEY ("gid") REFERENCES "guilds" ("gid");
ALTER TABLE "users" ADD FOREIGN KEY ("uid") REFERENCES "invites" ("uid");
ALTER TABLE "connections" ADD FOREIGN KEY ("fid") REFERENCES "users" ("uid");
ALTER TABLE "connections" ADD FOREIGN KEY ("tid") REFERENCES "users" ("uid");