vue-todo/bbconf/todo_datamodel.sql

33 lines
882 B
MySQL
Raw Normal View History

2023-02-28 13:57:08 +01:00
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");