1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| CREATE TABLE `referent` (
id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY
)ENGINE=InnoDB;
CREATE TABLE `contact` (
id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
id_ref INT UNSIGNED NOT NULL
)ENGINE=InnoDB;
CREATE TABLE `TJ_cont_ref_inter` (
id_TJ_ref INT UNSIGNED NOT NULL,
id_TJ_cont INT UNSIGNED NOT NULL,
id_TJ_inter INT UNSIGNED NOT NULL,
PRIMARY KEY (id_TJ_ref, id_TJ_cont, id_TJ_inter)
)ENGINE=InnoDB;
ALTER TABLE `contact`
ADD CONSTRAINT FK_cont_id_ref
FOREIGN KEY (id_ref) REFERENCES `referent` (id);
ALTER TABLE `TJ_cont_ref_inter`
ADD CONSTRAINT FK_TJ_cont_ref_inter_id_ref
FOREIGN KEY (id_TJ_ref) REFERENCES `referent` (id); |
Partager