From 228af15b446c840cafa5f21ac6336c7e31d00f3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20ARNAUDEAU?= Date: Mon, 23 Jan 2017 14:11:32 +0100 Subject: [PATCH] TG-104 : Modif structure BDD --- backend/OLA.mysql | 56 +++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/backend/OLA.mysql b/backend/OLA.mysql index ce8efea..e64984d 100644 --- a/backend/OLA.mysql +++ b/backend/OLA.mysql @@ -44,7 +44,7 @@ CREATE TABLE IF NOT EXISTS `USER` PRIMARY KEY(id) ) ENGINE = INNODB; -CREATE TABLE IF NOT EXISTS GROUP_CONTENT +CREATE TABLE IF NOT EXISTS TUTORSHIP ( id BIGINT NOT NULL AUTO_INCREMENT, group_id BIGINT NOT NULL, @@ -55,19 +55,19 @@ CREATE TABLE IF NOT EXISTS GROUP_CONTENT CREATE TABLE IF NOT EXISTS LIVRET ( - id BIGINT NOT NULL AUTO_INCREMENT, - group_content_id BIGINT, - etutor_name VARCHAR(128) NOT NULL, - etutor_email VARCHAR(256) NOT NULL, - etutor_phone VARCHAR(15) NOT NULL, - company_name VARCHAR(256) NOT NULL, - company_address VARCHAR(512) NOT NULL, - contract_type INT NOT NULL, - contract_start DATE NOT NULL, - contract_end DATE NOT NULL, - ressources_dir VARCHAR(512), - opened TINYINT(1) NOT NULL, - expire DATE NOT NULL, + id BIGINT NOT NULL AUTO_INCREMENT, + tutorship_id BIGINT, + etutor_name VARCHAR(128) NOT NULL, + etutor_email VARCHAR(256) NOT NULL, + etutor_phone VARCHAR(15) NOT NULL, + company_name VARCHAR(256) NOT NULL, + company_address VARCHAR(512) NOT NULL, + contract_type INT NOT NULL, + contract_start DATE NOT NULL, + contract_end DATE NOT NULL, + ressources_dir VARCHAR(512), + opened TINYINT(1) NOT NULL, + expire DATE NOT NULL, PRIMARY KEY(id) ) ENGINE = INNODB; @@ -86,9 +86,9 @@ CREATE TABLE IF NOT EXISTS PERIOD CREATE TABLE IF NOT EXISTS HASHTABLE ( - token VARCHAR(255) NOT NULL, - exipre DATE NOT NULL, - period INT NOT NULL, + token VARCHAR(255) NOT NULL, + exipre DATE NOT NULL, + period_id BIGINT NOT NULL, PRIMARY KEY(token) ) ENGINE = INNODB; @@ -98,34 +98,34 @@ ALTER TABLE `GROUP` ADD FOREIGN KEY (resp_id) REFERENCES `USER`(id) ; - -ALTER TABLE GROUP_CONTENT + +ALTER TABLE TUTORSHIP ADD FOREIGN KEY (group_id) REFERENCES `GROUP`(id) ON DELETE CASCADE ON UPDATE CASCADE ; - -ALTER TABLE GROUP_CONTENT + +ALTER TABLE TUTORSHIP ADD FOREIGN KEY (student_id) REFERENCES `USER`(id) ; - -ALTER TABLE GROUP_CONTENT + +ALTER TABLE TUTORSHIP ADD FOREIGN KEY (ptutor_id) REFERENCES `USER`(id) ; ALTER TABLE LIVRET - ADD FOREIGN KEY (group_content_id) - REFERENCES GROUP_CONTENT(id) + ADD FOREIGN KEY (tutorship_id) +REFERENCES TUTORSHIP (id) ON DELETE CASCADE ON UPDATE CASCADE ; ALTER TABLE LIVRET - ADD FOREIGN KEY (group_content_id) - REFERENCES GROUP_CONTENT(id) + ADD FOREIGN KEY (tutorship_id) +REFERENCES TUTORSHIP (id) ON DELETE CASCADE ON UPDATE CASCADE ; @@ -137,7 +137,7 @@ REFERENCES LIVRET (id) ON UPDATE CASCADE; ALTER TABLE HASHTABLE - ADD FOREIGN KEY (period) + ADD FOREIGN KEY (period_id) REFERENCES PERIOD (id) ON DELETE CASCADE ON UPDATE CASCADE