33 lines
882 B
SQL
33 lines
882 B
SQL
CREATE TABLE "List" (
|
|
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
|
|
"title" VARCHAR NOT NULL,
|
|
"user.username" VARCHAR NOT NULL
|
|
);
|
|
|
|
CREATE TABLE "Task" (
|
|
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
|
|
"title" VARCHAR NOT NULL,
|
|
"description" VARCHAR,
|
|
"completed" BOOLEAN NOT NULL,
|
|
"user.username" VARCHAR NOT NULL,
|
|
"list.id" UUID NOT NULL
|
|
);
|
|
|
|
CREATE TABLE "User" (
|
|
"username" VARCHAR NOT NULL,
|
|
"name" VARCHAR
|
|
);
|
|
|
|
ALTER TABLE "List" ADD PRIMARY KEY ("id");
|
|
|
|
ALTER TABLE "Task" ADD PRIMARY KEY ("id");
|
|
|
|
ALTER TABLE "User" ADD PRIMARY KEY ("username");
|
|
|
|
ALTER TABLE "List" ADD CONSTRAINT fk_list_1 FOREIGN KEY ("user.username") REFERENCES "User" ("username");
|
|
|
|
ALTER TABLE "Task" ADD CONSTRAINT fk_task_2 FOREIGN KEY ("user.username") REFERENCES "User" ("username");
|
|
|
|
ALTER TABLE "Task" ADD CONSTRAINT fk_task_3 FOREIGN KEY ("list.id") REFERENCES "List" ("id");
|
|
|