0% found this document useful (0 votes)
8 views4 pages

Hotelbd SQL

Uploaded by

Benst Joe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

Hotelbd SQL

Uploaded by

Benst Joe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

/*==============================================================*/

/* Nom de SGBD : MySQL 5.0 */


/* Date de cr�ation : 05/08/2021 15:27:27 */
/*==============================================================*/

drop table if exists CATEGORIES;

drop table if exists CHAMBRES;

drop table if exists CLASSES;

drop table if exists CLIENTS;

drop table if exists CONSOMMATIONS;

drop table if exists HOTELS;

drop table if exists OFFRIR;

drop table if exists PRESTATIONS;

drop table if exists RESERVATION;

drop table if exists SERVIR;

drop table if exists TARIFER;

/*==============================================================*/
/* Table : CATEGORIES */
/*==============================================================*/
create table CATEGORIES
(
CODE_CATEGORIE bool not null,
DESCRIPTION_ longtext not null,
primary key (CODE_CATEGORIE)
);

/*==============================================================*/
/* Table : CHAMBRES */
/*==============================================================*/
create table CHAMBRES
(
NUM_CHAMBRE int not null,
NUM_HOTEL longtext not null,
CODE_CATEGORIE bool not null,
TELEPHONE int not null,
NBRE_LIT int not null,
primary key (NUM_CHAMBRE)
);

/*==============================================================*/
/* Table : CLASSES */
/*==============================================================*/
create table CLASSES
(
CODE_CLASSE bool not null,
NBRE_ETOILE int not null,
primary key (CODE_CLASSE)
);

/*==============================================================*/
/* Table : CLIENTS */
/*==============================================================*/
create table CLIENTS
(
CODE_CLIENT char(10) not null,
NOM char(10) not null,
PRENOM char(10) not null,
ADRESSE char(10) not null,
VILLE char(10) not null,
PAYS char(10) not null,
TELEPHONE int not null,
AMAIL char(10) not null,
primary key (CODE_CLIENT)
);

/*==============================================================*/
/* Table : CONSOMMATIONS */
/*==============================================================*/
create table CONSOMMATIONS
(
NUM_CONSO int not null,
CODE_CLIENT char(10) not null,
DATE_CONSOMMATION_ date not null,
HEURE_CONSOMMATION time not null,
primary key (NUM_CONSO)
);

/*==============================================================*/
/* Table : HOTELS */
/*==============================================================*/
create table HOTELS
(
NUM_HOTEL longtext not null,
CODE_CLASSE bool not null,
ADRESSE_HOTEL longtext not null,
TELEPHONE int not null,
BP longtext not null,
SITE_WEB longtext not null,
primary key (NUM_HOTEL)
);

/*==============================================================*/
/* Table : OFFRIR */
/*==============================================================*/
create table OFFRIR
(
NUM_HOTEL longtext not null,
CODE_PRESTATION bool not null,
primary key (NUM_HOTEL, CODE_PRESTATION)
);

/*==============================================================*/
/* Table : PRESTATIONS */
/*==============================================================*/
create table PRESTATIONS
(
CODE_PRESTATION bool not null,
DESIGNATION longtext not null,
primary key (CODE_PRESTATION)
);

/*==============================================================*/
/* Table : RESERVATION */
/*==============================================================*/
create table RESERVATION
(
NUM_RESERVATIONS int not null,
CODE_CLIENT char(10) not null,
NUM_CHAMBRE int not null,
DATE_DEBUT date not null,
DATE_FIN date not null,
MONTANT_PAYER bool not null,
primary key (NUM_RESERVATIONS)
);

/*==============================================================*/
/* Table : SERVIR */
/*==============================================================*/
create table SERVIR
(
CODE_PRESTATION bool not null,
NUM_CONSO int not null,
primary key (CODE_PRESTATION, NUM_CONSO)
);

/*==============================================================*/
/* Table : TARIFER */
/*==============================================================*/
create table TARIFER
(
CODE_CATEGORIE bool not null,
CODE_CLASSE bool not null,
primary key (CODE_CATEGORIE, CODE_CLASSE)
);

alter table CHAMBRES add constraint FK_APPARTENIR foreign key (NUM_HOTEL)


references HOTELS (NUM_HOTEL) on delete restrict on update restrict;

alter table CHAMBRES add constraint FK_ETRE foreign key (CODE_CATEGORIE)


references CATEGORIES (CODE_CATEGORIE) on delete restrict on update restrict;

alter table CONSOMMATIONS add constraint FK_PRENDRE foreign key (CODE_CLIENT)


references CLIENTS (CODE_CLIENT) on delete restrict on update restrict;

alter table HOTELS add constraint FK_AVOIR foreign key (CODE_CLASSE)


references CLASSES (CODE_CLASSE) on delete restrict on update restrict;

alter table OFFRIR add constraint FK_OFFRIR foreign key (CODE_PRESTATION)


references PRESTATIONS (CODE_PRESTATION) on delete restrict on update
restrict;

alter table OFFRIR add constraint FK_OFFRIR2 foreign key (NUM_HOTEL)


references HOTELS (NUM_HOTEL) on delete restrict on update restrict;

alter table RESERVATION add constraint FK_CONCERNER foreign key (NUM_CHAMBRE)


references CHAMBRES (NUM_CHAMBRE) on delete restrict on update restrict;

alter table RESERVATION add constraint FK_EFFECTUER foreign key (CODE_CLIENT)


references CLIENTS (CODE_CLIENT) on delete restrict on update restrict;

alter table SERVIR add constraint FK_SERVIR foreign key (NUM_CONSO)


references CONSOMMATIONS (NUM_CONSO) on delete restrict on update restrict;

alter table SERVIR add constraint FK_SERVIR2 foreign key (CODE_PRESTATION)


references PRESTATIONS (CODE_PRESTATION) on delete restrict on update
restrict;

alter table TARIFER add constraint FK_TARIFER foreign key (CODE_CLASSE)


references CLASSES (CODE_CLASSE) on delete restrict on update restrict;

alter table TARIFER add constraint FK_TARIFER2 foreign key (CODE_CATEGORIE)


references CATEGORIES (CODE_CATEGORIE) on delete restrict on update restrict;

You might also like