Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

127.0.0.

1/phpmyadmin/
drop table specialite
CREATE TABLE specialite ( code_sp CHAR(3) NOT NULL ,
nom_sp VARCHAR(20) NOT NULL , PRIMARY KEY (code_sp))
CREATE TABLE `exo`.`enseignant` ( `mat_ens` INT NOT NULL AUTO_INCREMENT ,
`nom_ens` VARCHAR(20) NOT NULL , `prenom_ens` VARCHAR(20) NOT NULL ,
`dn_ens` DATE NOT NULL , `tel_ens` CHAR(9) NULL , `photo_ens` BLOB NULL ,
`code_sp` CHAR(3) NOT NULL ,
PRIMARY KEY (`mat_ens`))
alter table enseignant add constraint y1 foreign key (code_sp) references
specialite
(code_sp)

CREATE TABLE `exo`.`etudiant` ( `mat_etud` INT NOT NULL AUTO_INCREMENT ,


`nom_etud` VARCHAR(20) NOT NULL , `prenom_etud` VARCHAR(20) NOT NULL ,
`dn_etud` DATE NOT NULL , `tel_etud` CHAR(9) NULL , `photo_etud` BLOB NULL ,
`code_form` int NOT NULL ,
PRIMARY KEY (`mat_etud`), constraint y3 foreign key (code_form) references
formation
(code_form))
CREATE TABLE module ( code_mod INT NOT NULL AUTO_INCREMENT ,
nom_mod VARCHAR(20) NOT NULL , PRIMARY KEY (code_mod))

CREATE TABLE diplome ( num_dip INT NOT NULL AUTO_INCREMENT ,


`date_dip` DATE NOT NULL ,
mat_etud int NOT NULL ,
PRIMARY KEY (num_dip), constraint y4 foreign key (mat_etud) references etudiant
(mat_etud))

table plusieurs pusieurs

CREATE TABLE `exo`.`avoir` ( `code_form` INT NOT NULL ,


`code_mod` INT NOT NULL , `coef` INT(1) NOT NULL ,
PRIMARY KEY (`code_form`, `code_mod`))

alter table avoir add constraint y5 foreign key (code_form) references formation
(code_form);

alter table avoir add constraint y6 foreign key (code_mod) references module
(code_mod);

table noter :

CREATE TABLE exo . noter ( code_mod INT NOT NULL ,


mat_ens INT NOT NULL ,
mat_etud int not null , note decimal NOT NULL ,
PRIMARY KEY (code_mod, mat_ens ,mat_etud));

alter table avoir add constraint y7 foreign key (mat_ens) references enseignant
(mat_ens);

alter table avoir add constraint y8 foreign key (code_mod) references module
(code_mod);
alter table avoir add constraint y9 foreign key (mat_etud) references etudiant
(mat_etud);

You might also like