drop table if exists ANNEE;
drop table if exists CLASSE;
drop table if exists ETUDIANT;
drop table if exists FREQUENTER;
drop table if exists MODULE;
drop table if exists RESULTATS;
drop table if exists VILLE;
/*==============================================================*/
/* Table : ANNEE */
/*==============================================================*/
create table ANNEE
(
ID_ANNEE numeric(10,0) not null,
primary key (ID_ANNEE)
);
/*==============================================================*/
/* Table : CLASSE */
/*==============================================================*/
create table CLASSE
(
ID_CLASSE numeric(10,0) not null,
INTITULE varchar(20),
primary key (ID_CLASSE)
);
/*==============================================================*/
/* Table : ETUDIANT */
/*==============================================================*/
create table ETUDIANT
(
ID_ETUDIANT numeric(10,0) not null,
ID_VILLE numeric(10,0) not null,
NOM_ETUD varchar(1024),
PRENOM_ETUD varchar(1024),
primary key (ID_ETUDIANT)
);
/*==============================================================*/
/* Table : FREQUENTER */
/*==============================================================*/
create table FREQUENTER
(
ID_CLASSE numeric(10,0) not null,
ID_ANNEE numeric(10,0) not null,
ID_ETUDIANT numeric(10,0) not null,
primary key (ID_CLASSE, ID_ANNEE, ID_ETUDIANT)
);
/*==============================================================*/
/* Table : MODULE */
/*==============================================================*/
create table MODULE
(
ID_MODULE numeric(10,0) not null,
ID_CLASSE numeric(10,0) not null,
INTITULE_MODULE varchar(20),
COEF_MODULE int,
primary key (ID_MODULE)
);
/*==============================================================*/
/* Table : RESULTATS */
/*==============================================================*/
create table RESULTATS
(
ID_RESULTAT numeric(10,0) not null,
ID_ETUDIANT numeric(10,0) not null,
ID_MODULE numeric(10,0) not null,
EXAM decimal,
TD decimal,
TP decimal,
primary key (ID_RESULTAT)
);
/*==============================================================*/
/* Table : VILLE */
/*==============================================================*/
create table VILLE
(
ID_VILLE numeric(10,0) not null,
INTITULE_VILLE varchar(20),
primary key (ID_VILLE)
);
alter table ETUDIANT add constraint FK_HABITER foreign key (ID_VILLE)
references VILLE (ID_VILLE) on delete restrict on update restrict;
alter table FREQUENTER add constraint FK_FREQUENTER foreign key (ID_CLASSE)
references CLASSE (ID_CLASSE) on delete restrict on update restrict;
alter table FREQUENTER add constraint FK_FREQUENTER2 foreign key (ID_ANNEE)
references ANNEE (ID_ANNEE) on delete restrict on update restrict;
alter table FREQUENTER add constraint FK_FREQUENTER3 foreign key (ID_ETUDIANT)
references ETUDIANT (ID_ETUDIANT) on delete restrict on update restrict;
alter table MODULE add constraint FK_CLASSE_MODULE foreign key (ID_CLASSE)
references CLASSE (ID_CLASSE) on delete restrict on update restrict;
alter table RESULTATS add constraint FK_CONCERNE foreign key (ID_MODULE)
references MODULE (ID_MODULE) on delete restrict on update restrict;
alter table RESULTATS add constraint FK_OBTENIR foreign key (ID_ETUDIANT)
references ETUDIANT (ID_ETUDIANT) on delete restrict on update restrict;