1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
//table direction
CREATE TABLE direction(
id_direction int (11) Auto_increment NOT NULL ,
code_direction Varchar (25) NOT NULL ,
nom_direction Varchar (50) NOT NULL ,
PRIMARY KEY (id_direction )
)ENGINE=InnoDB;
// table service
CREATE TABLE service(
id_service int (11) Auto_increment NOT NULL ,
code_service Varchar (25) ,
nom_service Varchar (50) NOT NULL ,
id_direction Int ,
PRIMARY KEY (id_service )
)ENGINE=InnoDB;
// division
CREATE TABLE division(
id_division int (11) Auto_increment NOT NULL ,
nom_division Varchar (25) NOT NULL ,
id_service Int ,
PRIMARY KEY (id_division )
)ENGINE=InnoDB;
//poste
CREATE TABLE poste(
id_poste int (11) Auto_increment NOT NULL ,
code_poste Varchar (25) ,
nom_poste Varchar (25) NOT NULL ,
id_division Int ,
id_direction Int ,
id_service Int ,
PRIMARY KEY (id_poste )
)ENGINE=InnoDB;
//definition les contraintes des cle etranger
ALTER TABLE poste ADD CONSTRAINT FK_poste_id_division FOREIGN KEY (id_division) REFERENCES division(id_division);
ALTER TABLE poste ADD CONSTRAINT FK_poste_id_direction FOREIGN KEY (id_direction) REFERENCES direction(id_direction);
ALTER TABLE poste ADD CONSTRAINT FK_poste_id_service FOREIGN KEY (id_service) REFERENCES service(id_service); |
Partager