Sei sulla pagina 1di 6

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

/* Nom de SGBD : Sybase SQL Anywhere 11 */


/* Date de création : 12/11/2019 20:35:54 */
/*==============================================================*/

if exists(select 1 from sys.sysforeignkey where


role='FK_BON_COMM_PASSER_RESTAURA') then
alter table BON_COMMANDE
delete foreign key FK_BON_COMM_PASSER_RESTAURA
end if;

if exists(select 1 from sys.sysforeignkey where


role='FK_BON_LIVR_LIVRER_FOURNISS') then
alter table BON_LIVRAISON
delete foreign key FK_BON_LIVR_LIVRER_FOURNISS
end if;

if exists(select 1 from sys.sysforeignkey where


role='FK_BON_PREL_EFFECTUER_RESTAURA') then
alter table BON_PRELEVEMENT
delete foreign key FK_BON_PREL_EFFECTUER_RESTAURA
end if;

if exists(select 1 from sys.sysforeignkey where


role='FK_COMPORTE_COMPORTER_MENU') then
alter table COMPORTER
delete foreign key FK_COMPORTE_COMPORTER_MENU
end if;

if exists(select 1 from sys.sysforeignkey where


role='FK_CONCERNE_CONCERNE_FOURNISS') then
alter table CONCERNE
delete foreign key FK_CONCERNE_CONCERNE_FOURNISS
end if;

if exists(select 1 from sys.sysforeignkey where


role='FK_CONCERNE_CONCERNE2_BON_COMM') then
alter table CONCERNE
delete foreign key FK_CONCERNE_CONCERNE2_BON_COMM
end if;

if exists(select 1 from sys.sysforeignkey where


role='FK_CONTIENT_CONTIENT_BON_COMM') then
alter table CONTIENT
delete foreign key FK_CONTIENT_CONTIENT_BON_COMM
end if;

if exists(select 1 from sys.sysforeignkey where


role='FK_MENU_ETABLIR_RESTAURA') then
alter table MENU
delete foreign key FK_MENU_ETABLIR_RESTAURA
end if;
if exists(select 1 from sys.sysforeignkey where
role='FK_POSSEDER_POSSEDER__FOURNISS') then
alter table POSSEDER_CATALOGUE
delete foreign key FK_POSSEDER_POSSEDER__FOURNISS
end if;

if exists(
select 1 from sys.systable
where table_name='BON_COMMANDE'
and table_type in ('BASE', 'GBL TEMP')
) then
drop table BON_COMMANDE
end if;

if exists(
select 1 from sys.systable
where table_name='BON_LIVRAISON'
and table_type in ('BASE', 'GBL TEMP')
) then
drop table BON_LIVRAISON
end if;

if exists(
select 1 from sys.systable
where table_name='BON_PRELEVEMENT'
and table_type in ('BASE', 'GBL TEMP')
) then
drop table BON_PRELEVEMENT
end if;

if exists(
select 1 from sys.systable
where table_name='COMPORTER'
and table_type in ('BASE', 'GBL TEMP')
) then
drop table COMPORTER
end if;

if exists(
select 1 from sys.systable
where table_name='CONCERNE'
and table_type in ('BASE', 'GBL TEMP')
) then
drop table CONCERNE
end if;

if exists(
select 1 from sys.systable
where table_name='CONTIENT'
and table_type in ('BASE', 'GBL TEMP')
) then
drop table CONTIENT
end if;
if exists(
select 1 from sys.systable
where table_name='FOURNISSUER'
and table_type in ('BASE', 'GBL TEMP')
) then
drop table FOURNISSUER
end if;

if exists(
select 1 from sys.systable
where table_name='MENU'
and table_type in ('BASE', 'GBL TEMP')
) then
drop table MENU
end if;

if exists(
select 1 from sys.systable
where table_name='POSSEDER_CATALOGUE'
and table_type in ('BASE', 'GBL TEMP')
) then
drop table POSSEDER_CATALOGUE
end if;

if exists(
select 1 from sys.systable
where table_name='RESTAURANT'
and table_type in ('BASE', 'GBL TEMP')
) then
drop table RESTAURANT
end if;

/*==============================================================*/
/* Table : BON_COMMANDE */
/*==============================================================*/
create table BON_COMMANDE
(
ID_BON_COM numeric not null,
ID_RESTO numeric not null,
DATE_BON_COM date null,
constraint PK_BON_COMMANDE primary key (ID_BON_COM)
);

/*==============================================================*/
/* Table : BON_LIVRAISON */
/*==============================================================*/
create table BON_LIVRAISON
(
ID_BON_LAIVR numeric not null,
ID_FOURNISSEUR numeric not null,
DATE_BON_LAIVR date null,
constraint PK_BON_LIVRAISON primary key (ID_BON_LAIVR)
);
/*==============================================================*/
/* Table : BON_PRELEVEMENT */
/*==============================================================*/
create table BON_PRELEVEMENT
(
ID_BON_PRELEV numeric not null,
ID_RESTO numeric not null,
DATE_BON_PRELEV date null,
constraint PK_BON_PRELEVEMENT primary key (ID_BON_PRELEV)
);

/*==============================================================*/
/* Table : COMPORTER */
/*==============================================================*/
create table COMPORTER
(
ID_ARTICLE numeric not null,
ID_MENU numeric not null,
constraint PK_COMPORTER primary key (ID_ARTICLE, ID_MENU)
);

/*==============================================================*/
/* Table : CONCERNE */
/*==============================================================*/
create table CONCERNE
(
ID_BON_COM numeric not null,
ID_FOURNISSEUR numeric not null,
constraint PK_CONCERNE primary key (ID_BON_COM, ID_FOURNISSEUR)
);

/*==============================================================*/
/* Table : CONTIENT */
/*==============================================================*/
create table CONTIENT
(
ID_ARTICLE numeric not null,
ID_BON_COM numeric not null,
constraint PK_CONTIENT primary key (ID_ARTICLE, ID_BON_COM)
);

/*==============================================================*/
/* Table : FOURNISSUER */
/*==============================================================*/
create table FOURNISSUER
(
ID_FOURNISSEUR numeric not null,
NOM_FOURNISSEUR varchar(50) null,
ADD_FOURNISSEUR varchar(250) null,
TEL_FOURNISSEUR numeric null,
SPECIALITE varchar(50) null,
constraint PK_FOURNISSUER primary key (ID_FOURNISSEUR)
);
/*==============================================================*/
/* Table : MENU */
/*==============================================================*/
create table MENU
(
ID_MENU numeric not null,
ID_RESTO numeric not null,
ENTRE varchar(100) null,
PLAT varchar(100) null,
DESSERT varchar(100) null,
DATE_MENU date null,
constraint PK_MENU primary key (ID_MENU)
);

/*==============================================================*/
/* Table : POSSEDER_CATALOGUE */
/*==============================================================*/
create table POSSEDER_CATALOGUE
(
ID_ARTICLE numeric not null,
ID_FOURNISSEUR numeric not null,
constraint PK_POSSEDER_CATALOGUE primary key (ID_ARTICLE,
ID_FOURNISSEUR)
);

/*==============================================================*/
/* Table : RESTAURANT */
/*==============================================================*/
create table RESTAURANT
(
ID_RESTO numeric not null,
TYPE_RESTO varchar(50) null,
NBR_BENEFICIAIRE numeric null,
constraint PK_RESTAURANT primary key (ID_RESTO)
);

alter table BON_COMMANDE


add constraint FK_BON_COMM_PASSER_RESTAURA foreign key (ID_RESTO)
references RESTAURANT (ID_RESTO)
on update restrict
on delete restrict;

alter table BON_LIVRAISON


add constraint FK_BON_LIVR_LIVRER_FOURNISS foreign key
(ID_FOURNISSEUR)
references FOURNISSUER (ID_FOURNISSEUR)
on update restrict
on delete restrict;

alter table BON_PRELEVEMENT


add constraint FK_BON_PREL_EFFECTUER_RESTAURA foreign key (ID_RESTO)
references RESTAURANT (ID_RESTO)
on update restrict
on delete restrict;
alter table COMPORTER
add constraint FK_COMPORTE_COMPORTER_MENU foreign key (ID_MENU)
references MENU (ID_MENU)
on update restrict
on delete restrict;

alter table CONCERNE


add constraint FK_CONCERNE_CONCERNE_FOURNISS foreign key
(ID_FOURNISSEUR)
references FOURNISSUER (ID_FOURNISSEUR)
on update restrict
on delete restrict;

alter table CONCERNE


add constraint FK_CONCERNE_CONCERNE2_BON_COMM foreign key (ID_BON_COM)
references BON_COMMANDE (ID_BON_COM)
on update restrict
on delete restrict;

alter table CONTIENT


add constraint FK_CONTIENT_CONTIENT_BON_COMM foreign key (ID_BON_COM)
references BON_COMMANDE (ID_BON_COM)
on update restrict
on delete restrict;

alter table MENU


add constraint FK_MENU_ETABLIR_RESTAURA foreign key (ID_RESTO)
references RESTAURANT (ID_RESTO)
on update restrict
on delete restrict;

alter table POSSEDER_CATALOGUE


add constraint FK_POSSEDER_POSSEDER__FOURNISS foreign key
(ID_FOURNISSEUR)
references FOURNISSUER (ID_FOURNISSEUR)
on update restrict
on delete restrict;

Potrebbero piacerti anche