TG-104 : Modif structure BDD

This commit is contained in:
Clément ARNAUDEAU 2017-01-23 14:11:32 +01:00
parent 534af3f7bb
commit 228af15b44

View File

@ -44,7 +44,7 @@ CREATE TABLE IF NOT EXISTS `USER`
PRIMARY KEY(id) PRIMARY KEY(id)
) ENGINE = INNODB; ) ENGINE = INNODB;
CREATE TABLE IF NOT EXISTS GROUP_CONTENT CREATE TABLE IF NOT EXISTS TUTORSHIP
( (
id BIGINT NOT NULL AUTO_INCREMENT, id BIGINT NOT NULL AUTO_INCREMENT,
group_id BIGINT NOT NULL, group_id BIGINT NOT NULL,
@ -56,7 +56,7 @@ CREATE TABLE IF NOT EXISTS GROUP_CONTENT
CREATE TABLE IF NOT EXISTS LIVRET CREATE TABLE IF NOT EXISTS LIVRET
( (
id BIGINT NOT NULL AUTO_INCREMENT, id BIGINT NOT NULL AUTO_INCREMENT,
group_content_id BIGINT, tutorship_id BIGINT,
etutor_name VARCHAR(128) NOT NULL, etutor_name VARCHAR(128) NOT NULL,
etutor_email VARCHAR(256) NOT NULL, etutor_email VARCHAR(256) NOT NULL,
etutor_phone VARCHAR(15) NOT NULL, etutor_phone VARCHAR(15) NOT NULL,
@ -88,7 +88,7 @@ CREATE TABLE IF NOT EXISTS HASHTABLE
( (
token VARCHAR(255) NOT NULL, token VARCHAR(255) NOT NULL,
exipre DATE NOT NULL, exipre DATE NOT NULL,
period INT NOT NULL, period_id BIGINT NOT NULL,
PRIMARY KEY(token) PRIMARY KEY(token)
) ENGINE = INNODB; ) ENGINE = INNODB;
@ -99,33 +99,33 @@ ALTER TABLE `GROUP`
REFERENCES `USER`(id) REFERENCES `USER`(id)
; ;
ALTER TABLE GROUP_CONTENT ALTER TABLE TUTORSHIP
ADD FOREIGN KEY (group_id) ADD FOREIGN KEY (group_id)
REFERENCES `GROUP`(id) REFERENCES `GROUP`(id)
ON DELETE CASCADE ON DELETE CASCADE
ON UPDATE CASCADE ON UPDATE CASCADE
; ;
ALTER TABLE GROUP_CONTENT ALTER TABLE TUTORSHIP
ADD FOREIGN KEY (student_id) ADD FOREIGN KEY (student_id)
REFERENCES `USER`(id) REFERENCES `USER`(id)
; ;
ALTER TABLE GROUP_CONTENT ALTER TABLE TUTORSHIP
ADD FOREIGN KEY (ptutor_id) ADD FOREIGN KEY (ptutor_id)
REFERENCES `USER`(id) REFERENCES `USER`(id)
; ;
ALTER TABLE LIVRET ALTER TABLE LIVRET
ADD FOREIGN KEY (group_content_id) ADD FOREIGN KEY (tutorship_id)
REFERENCES GROUP_CONTENT(id) REFERENCES TUTORSHIP (id)
ON DELETE CASCADE ON DELETE CASCADE
ON UPDATE CASCADE ON UPDATE CASCADE
; ;
ALTER TABLE LIVRET ALTER TABLE LIVRET
ADD FOREIGN KEY (group_content_id) ADD FOREIGN KEY (tutorship_id)
REFERENCES GROUP_CONTENT(id) REFERENCES TUTORSHIP (id)
ON DELETE CASCADE ON DELETE CASCADE
ON UPDATE CASCADE ON UPDATE CASCADE
; ;
@ -137,7 +137,7 @@ REFERENCES LIVRET (id)
ON UPDATE CASCADE; ON UPDATE CASCADE;
ALTER TABLE HASHTABLE ALTER TABLE HASHTABLE
ADD FOREIGN KEY (period) ADD FOREIGN KEY (period_id)
REFERENCES PERIOD (id) REFERENCES PERIOD (id)
ON DELETE CASCADE ON DELETE CASCADE
ON UPDATE CASCADE ON UPDATE CASCADE