forked from oslabs-beta/ohana
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKlustrSchema2.sql
44 lines (35 loc) · 1.01 KB
/
KlustrSchema2.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
CREATE TABLE "users" (
"_id" smallserial PRIMARY KEY,
"email" varchar,
"password" varchar,
"first_name" varchar,
"last_name" varchar,
"is_admin" varchar,
"team_id" smallint
);
CREATE TABLE "teams" (
"_id" smallserial PRIMARY KEY,
"name" varchar
);
CREATE TABLE "namespaces" (
"_id" smallserial PRIMARY KEY,
"name" varchar,
"cluster_id" smallint
team_id
);
CREATE TABLE "vclusters" (
"_id" smallserial PRIMARY KEY,
"name" varchar,
"owner_id" smallint,
"team_id" smallint,
"namespace_id" smallint
);
CREATE TABLE "clusters" (
"_id" smallserial PRIMARY KEY,
"name" varchar
);
ALTER TABLE "users" ADD FOREIGN KEY ("team_id") REFERENCES "teams" ("_id");
ALTER TABLE "vclusters" ADD FOREIGN KEY ("namespace_id") REFERENCES "namespaces" ("_id");
ALTER TABLE "vclusters" ADD FOREIGN KEY ("owner_id") REFERENCES "users" ("_id");
ALTER TABLE "vclusters" ADD FOREIGN KEY ("team_id") REFERENCES "teams" ("_id");
ALTER TABLE "namespaces" ADD FOREIGN KEY ("cluster_id") REFERENCES "clusters" ("_id");