mirror of
https://github.com/Lemonochrme/service-architecture.git
synced 2025-06-08 13:40:50 +02:00
Added Database V1
This commit is contained in:
parent
607ae2c3e8
commit
747f6e2943
1 changed files with 41 additions and 0 deletions
41
db/db.sql
Normal file
41
db/db.sql
Normal file
|
@ -0,0 +1,41 @@
|
|||
CREATE TABLE `users` (
|
||||
`id` integer UNIQUE PRIMARY KEY NOT NULL,
|
||||
`id_role` integer NOT NULL,
|
||||
`username` text UNIQUE NOT NULL,
|
||||
`password` text NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE `roles` (
|
||||
`id` integer UNIQUE PRIMARY KEY NOT NULL,
|
||||
`name` text UNIQUE NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE `status` (
|
||||
`id` integer UNIQUE PRIMARY KEY NOT NULL,
|
||||
`name` text UNIQUE NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE `requests` (
|
||||
`id` integer UNIQUE PRIMARY KEY NOT NULL,
|
||||
`id_status` integer NOT NULL,
|
||||
`id_user` integer NOT NULL,
|
||||
`created_at` date DEFAULT (now()),
|
||||
`message` text NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE `feedback` (
|
||||
`id` integer UNIQUE PRIMARY KEY NOT NULL,
|
||||
`id_user` integer NOT NULL,
|
||||
`id_request` integer NOT NULL,
|
||||
`message` text NOT NULL
|
||||
);
|
||||
|
||||
ALTER TABLE `roles` ADD FOREIGN KEY (`id`) REFERENCES `users` (`id_role`);
|
||||
|
||||
ALTER TABLE `users` ADD FOREIGN KEY (`id`) REFERENCES `requests` (`id_user`);
|
||||
|
||||
ALTER TABLE `status` ADD FOREIGN KEY (`id`) REFERENCES `requests` (`id_status`);
|
||||
|
||||
ALTER TABLE `users` ADD FOREIGN KEY (`id`) REFERENCES `feedback` (`id_user`);
|
||||
|
||||
ALTER TABLE `requests` ADD FOREIGN KEY (`id`) REFERENCES `feedback` (`id_request`);
|
Loading…
Add table
Reference in a new issue