vue-todo/bbconf/bb_todo-datamodel.sql

33 lines
882 B
MySQL
Raw Normal View History

2023-02-12 11:36:19 +01:00
CREATE TABLE "List" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"title" VARCHAR NOT NULL,
2023-02-16 22:19:09 +01:00
"user_username" VARCHAR NOT NULL
2023-02-12 11:36:19 +01:00
);
CREATE TABLE "Task" (
"id" UUID DEFAULT gen_random_uuid() NOT NULL,
"title" VARCHAR NOT NULL,
"description" VARCHAR,
"completed" BOOLEAN NOT NULL,
2023-02-16 22:19:09 +01:00
"user_username" VARCHAR NOT NULL,
"list_id" UUID NOT NULL
2023-02-12 11:36:19 +01:00
);
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");
2023-02-16 22:19:09 +01:00
ALTER TABLE "List" ADD CONSTRAINT fk_list_1 FOREIGN KEY ("user_username") REFERENCES "User" ("username");
2023-02-12 11:36:19 +01:00
2023-02-16 22:19:09 +01:00
ALTER TABLE "Task" ADD CONSTRAINT fk_task_2 FOREIGN KEY ("user_username") REFERENCES "User" ("username");
2023-02-12 11:36:19 +01:00
2023-02-16 22:19:09 +01:00
ALTER TABLE "Task" ADD CONSTRAINT fk_task_3 FOREIGN KEY ("list_id") REFERENCES "List" ("id");
2023-02-12 11:36:19 +01:00