/*==============================================================*/ /* Database name: MODELEPHYSIQUE */ /* DBMS name: PostgreSQL 7 */ /* Created on: 13/11/2002 13:42:46 */ /*==============================================================*/ drop index ACHAT2_FK; drop index ACHAT3_FK; drop index ACHAT_FK; drop index ACHAT_PK; drop index ACTIVITE_PK; drop index PROPOSE_FK; drop index ADHERENT_PK; drop index INSCRIPTION_FK; drop index BANQUE_PK; drop index CAISSE_PK; drop index CAISSECHEQUE_PK; drop index CAISSEESPECE_PK; drop index CHEQUEEMIS_PK; drop index DEBIT_FK; drop index PAYE_FK; drop index CHEQUERECU_PK; drop index CONTIENT_FK; drop index IMPRIME_FK; drop index CLUB_PK; drop index APPARTIENT_FK; drop index COMPTE_PK; drop index DEPARTEMENT_PK; drop index DESTINATAIRE_PK; drop index FACTURE_PK; drop index FOURNISSEUR_PK; drop index LIVRE2_FK; drop index LIVRE_FK; drop index LIVRE_PK; drop index OBJET_PK; drop index PERSONNE_PK; drop index PRODUIT_PK; drop index QUANTITE2_FK; drop index QUANTITE_FK; drop index QUANTITE_PK; drop index REMISE2_FK; drop index REMISE_FK; drop index REMISE_PK; drop index SPONSORS_PK; drop index REFERENCE_FK; drop index STOCK_PK; drop table ACHAT; drop table ACTIVITE; drop table ADHERENT; drop table BANQUE; drop table CAISSE; drop table CAISSECHEQUE; drop table CAISSEESPECE; drop table CHEQUEEMIS; drop table CHEQUERECU; drop table CLUB; drop table COMPTE; drop table DEPARTEMENT; drop table DESTINATAIRE; drop table FACTURE; drop table FOURNISSEUR; drop table LIVRE; drop table OBJET; drop table PERSONNE; drop table PRODUIT; drop table QUANTITE; drop table REMISE; drop table SPONSORS; drop table STOCK; /*==============================================================*/ /* Table: ACHAT */ /*==============================================================*/ create table ACHAT ( ID_PERSONNE INT4 not null, ID_FACTURE INT4 not null, ID_CAISSE INT4 not null, DATE DATE null, constraint PK_ACHAT primary key (ID_PERSONNE, ID_FACTURE, ID_CAISSE) ); /*==============================================================*/ /* Index: ACHAT_PK */ /*==============================================================*/ create unique index ACHAT_PK on ACHAT ( ID_PERSONNE, ID_FACTURE, ID_CAISSE ); /*==============================================================*/ /* Index: ACHAT_FK */ /*==============================================================*/ create index ACHAT_FK on ACHAT ( ID_PERSONNE ); /*==============================================================*/ /* Index: ACHAT2_FK */ /*==============================================================*/ create index ACHAT2_FK on ACHAT ( ID_FACTURE ); /*==============================================================*/ /* Index: ACHAT3_FK */ /*==============================================================*/ create index ACHAT3_FK on ACHAT ( ID_CAISSE ); /*==============================================================*/ /* Table: ACTIVITE */ /*==============================================================*/ create table ACTIVITE ( ID_OBJET INT4 not null, ID_DESTINATAIRE INT4 not null, NOM_OBJET TEXT null, PRIX_AVEC FLOAT8 null, PRIX_SANS FLOAT8 null, constraint PK_ACTIVITE primary key (ID_OBJET) ); /*==============================================================*/ /* Index: ACTIVITE_PK */ /*==============================================================*/ create unique index ACTIVITE_PK on ACTIVITE ( ID_OBJET ); /*==============================================================*/ /* Index: PROPOSE_FK */ /*==============================================================*/ create index PROPOSE_FK on ACTIVITE ( ID_DESTINATAIRE ); /*==============================================================*/ /* Table: ADHERENT */ /*==============================================================*/ create table ADHERENT ( ID_PERSONNE INT4 not null, ID_DEPARTEMENT INT4 not null, NOM_OBJET TEXT null, NUMERO_ADHERENT INT4 null, PRENOM TEXT null, ANNEE_CIVILE NUMERIC null, constraint PK_ADHERENT primary key (ID_PERSONNE) ); /*==============================================================*/ /* Index: ADHERENT_PK */ /*==============================================================*/ create unique index ADHERENT_PK on ADHERENT ( ID_PERSONNE ); /*==============================================================*/ /* Index: INSCRIPTION_FK */ /*==============================================================*/ create index INSCRIPTION_FK on ADHERENT ( ID_DEPARTEMENT ); /*==============================================================*/ /* Table: BANQUE */ /*==============================================================*/ create table BANQUE ( ID_BANQUE SERIAL not null, NOM TEXT null, constraint PK_BANQUE primary key (ID_BANQUE) ); /*==============================================================*/ /* Index: BANQUE_PK */ /*==============================================================*/ create unique index BANQUE_PK on BANQUE ( ID_BANQUE ); /*==============================================================*/ /* Table: CAISSE */ /*==============================================================*/ create table CAISSE ( ID_CAISSE SERIAL not null, MONTANT FLOAT8 null, SITE TEXT null, constraint PK_CAISSE primary key (ID_CAISSE) ); /*==============================================================*/ /* Index: CAISSE_PK */ /*==============================================================*/ create unique index CAISSE_PK on CAISSE ( ID_CAISSE ); /*==============================================================*/ /* Table: CAISSECHEQUE */ /*==============================================================*/ create table CAISSECHEQUE ( ID_CAISSE INT4 not null, MONTANT FLOAT8 null, SITE TEXT null, constraint PK_CAISSECHEQUE primary key (ID_CAISSE) ); /*==============================================================*/ /* Index: CAISSECHEQUE_PK */ /*==============================================================*/ create unique index CAISSECHEQUE_PK on CAISSECHEQUE ( ID_CAISSE ); /*==============================================================*/ /* Table: CAISSEESPECE */ /*==============================================================*/ create table CAISSEESPECE ( ID_CAISSE INT4 not null, MONTANT FLOAT8 null, SITE TEXT null, constraint PK_CAISSEESPECE primary key (ID_CAISSE) ); /*==============================================================*/ /* Index: CAISSEESPECE_PK */ /*==============================================================*/ create unique index CAISSEESPECE_PK on CAISSEESPECE ( ID_CAISSE ); /*==============================================================*/ /* Table: CHEQUEEMIS */ /*==============================================================*/ create table CHEQUEEMIS ( NUMERO_CHEQUEEMIS NUMERIC null, ORDRE TEXT null, DATE_EMISSION DATE null, JUSTIFICATIF TEXT null, CATEGORIE TEXT null, ID_CHEQUEEMIS SERIAL not null, NUMERO_COMPTE INT4 not null, ID_DESTINATAIRE INT4 not null, ETAT TEXT null, constraint PK_CHEQUEEMIS primary key (ID_CHEQUEEMIS) ); /*==============================================================*/ /* Index: CHEQUEEMIS_PK */ /*==============================================================*/ create unique index CHEQUEEMIS_PK on CHEQUEEMIS ( ID_CHEQUEEMIS ); /*==============================================================*/ /* Index: PAYE_FK */ /*==============================================================*/ create index PAYE_FK on CHEQUEEMIS ( ID_DESTINATAIRE ); /*==============================================================*/ /* Index: DEBIT_FK */ /*==============================================================*/ create index DEBIT_FK on CHEQUEEMIS ( NUMERO_COMPTE ); /*==============================================================*/ /* Table: CHEQUERECU */ /*==============================================================*/ create table CHEQUERECU ( ID_CHEQUERECU SERIAL not null, ID_BANQUE INT4 not null, ID_CAISSE INT4 not null, NUMERO_CHEQUERECU NUMERIC null, NOM_TIRE TEXT null, VILLE_COMPENSATION TEXT null, ETAT TEXT null, constraint PK_CHEQUERECU primary key (ID_CHEQUERECU) ); /*==============================================================*/ /* Index: CHEQUERECU_PK */ /*==============================================================*/ create unique index CHEQUERECU_PK on CHEQUERECU ( ID_CHEQUERECU ); /*==============================================================*/ /* Index: CONTIENT_FK */ /*==============================================================*/ create index CONTIENT_FK on CHEQUERECU ( ID_CAISSE ); /*==============================================================*/ /* Index: IMPRIME_FK */ /*==============================================================*/ create index IMPRIME_FK on CHEQUERECU ( ID_BANQUE ); /*==============================================================*/ /* Table: CLUB */ /*==============================================================*/ create table CLUB ( ID_DESTINATAIRE INT4 not null, NOM TEXT null, PRESIDENT TEXT null, BUDGET FLOAT8 null, DEPENSE FLOAT8 null, SUBVENTION FLOAT8 null, constraint PK_CLUB primary key (ID_DESTINATAIRE) ); /*==============================================================*/ /* Index: CLUB_PK */ /*==============================================================*/ create unique index CLUB_PK on CLUB ( ID_DESTINATAIRE ); /*==============================================================*/ /* Table: COMPTE */ /*==============================================================*/ create table COMPTE ( NUMERO_COMPTE SERIAL not null, ID_BANQUE INT4 not null, constraint PK_COMPTE primary key (NUMERO_COMPTE) ); /*==============================================================*/ /* Index: COMPTE_PK */ /*==============================================================*/ create unique index COMPTE_PK on COMPTE ( NUMERO_COMPTE ); /*==============================================================*/ /* Index: APPARTIENT_FK */ /*==============================================================*/ create index APPARTIENT_FK on COMPTE ( ID_BANQUE ); /*==============================================================*/ /* Table: DEPARTEMENT */ /*==============================================================*/ create table DEPARTEMENT ( NOM_OBJET TEXT null, ANNEE_INSA INT4 null, ID_DEPARTEMENT SERIAL not null, constraint PK_DEPARTEMENT primary key (ID_DEPARTEMENT) ); /*==============================================================*/ /* Index: DEPARTEMENT_PK */ /*==============================================================*/ create unique index DEPARTEMENT_PK on DEPARTEMENT ( ID_DEPARTEMENT ); /*==============================================================*/ /* Table: DESTINATAIRE */ /*==============================================================*/ create table DESTINATAIRE ( NOM TEXT null, ID_DESTINATAIRE SERIAL not null, constraint PK_DESTINATAIRE primary key (ID_DESTINATAIRE) ); /*==============================================================*/ /* Index: DESTINATAIRE_PK */ /*==============================================================*/ create unique index DESTINATAIRE_PK on DESTINATAIRE ( ID_DESTINATAIRE ); /*==============================================================*/ /* Table: FACTURE */ /*==============================================================*/ create table FACTURE ( ID_FACTURE SERIAL not null, constraint PK_FACTURE primary key (ID_FACTURE) ); /*==============================================================*/ /* Index: FACTURE_PK */ /*==============================================================*/ create unique index FACTURE_PK on FACTURE ( ID_FACTURE ); /*==============================================================*/ /* Table: FOURNISSEUR */ /*==============================================================*/ create table FOURNISSEUR ( ID_DESTINATAIRE INT4 not null, NOM TEXT null, TELEPHONE TEXT null, CONTACT TEXT null, constraint PK_FOURNISSEUR primary key (ID_DESTINATAIRE) ); /*==============================================================*/ /* Index: FOURNISSEUR_PK */ /*==============================================================*/ create unique index FOURNISSEUR_PK on FOURNISSEUR ( ID_DESTINATAIRE ); /*==============================================================*/ /* Table: LIVRE */ /*==============================================================*/ create table LIVRE ( ID_OBJET INT4 not null, ID_DESTINATAIRE INT4 not null, DATE DATE null, QUANTITE INT4 null, constraint PK_LIVRE primary key (ID_OBJET, ID_DESTINATAIRE) ); /*==============================================================*/ /* Index: LIVRE_PK */ /*==============================================================*/ create unique index LIVRE_PK on LIVRE ( ID_OBJET, ID_DESTINATAIRE ); /*==============================================================*/ /* Index: LIVRE_FK */ /*==============================================================*/ create index LIVRE_FK on LIVRE ( ID_OBJET ); /*==============================================================*/ /* Index: LIVRE2_FK */ /*==============================================================*/ create index LIVRE2_FK on LIVRE ( ID_DESTINATAIRE ); /*==============================================================*/ /* Table: OBJET */ /*==============================================================*/ create table OBJET ( NOM_OBJET TEXT null, PRIX_AVEC FLOAT8 null, PRIX_SANS FLOAT8 null, ID_OBJET SERIAL not null, constraint PK_OBJET primary key (ID_OBJET) ); /*==============================================================*/ /* Index: OBJET_PK */ /*==============================================================*/ create unique index OBJET_PK on OBJET ( ID_OBJET ); /*==============================================================*/ /* Table: PERSONNE */ /*==============================================================*/ create table PERSONNE ( NOM_OBJET TEXT null, ID_PERSONNE SERIAL not null, constraint PK_PERSONNE primary key (ID_PERSONNE) ); /*==============================================================*/ /* Index: PERSONNE_PK */ /*==============================================================*/ create unique index PERSONNE_PK on PERSONNE ( ID_PERSONNE ); /*==============================================================*/ /* Table: PRODUIT */ /*==============================================================*/ create table PRODUIT ( ID_OBJET INT4 not null, NOM_OBJET TEXT null, PRIX_AVEC FLOAT8 null, PRIX_SANS FLOAT8 null, CATEGORIE TEXT null, constraint PK_PRODUIT primary key (ID_OBJET) ); /*==============================================================*/ /* Index: PRODUIT_PK */ /*==============================================================*/ create unique index PRODUIT_PK on PRODUIT ( ID_OBJET ); /*==============================================================*/ /* Table: QUANTITE */ /*==============================================================*/ create table QUANTITE ( ID_FACTURE INT4 not null, ID_OBJET INT4 not null, QUANTITE INT4 null, constraint PK_QUANTITE primary key (ID_FACTURE, ID_OBJET) ); /*==============================================================*/ /* Index: QUANTITE_PK */ /*==============================================================*/ create unique index QUANTITE_PK on QUANTITE ( ID_FACTURE, ID_OBJET ); /*==============================================================*/ /* Index: QUANTITE_FK */ /*==============================================================*/ create index QUANTITE_FK on QUANTITE ( ID_FACTURE ); /*==============================================================*/ /* Index: QUANTITE2_FK */ /*==============================================================*/ create index QUANTITE2_FK on QUANTITE ( ID_OBJET ); /*==============================================================*/ /* Table: REMISE */ /*==============================================================*/ create table REMISE ( ID_CAISSE INT4 not null, NUMERO_COMPTE INT4 not null, DATE DATE null, MONTANT FLOAT8 null, ETAT TEXT null, constraint PK_REMISE primary key (ID_CAISSE, NUMERO_COMPTE) ); /*==============================================================*/ /* Index: REMISE_PK */ /*==============================================================*/ create unique index REMISE_PK on REMISE ( ID_CAISSE, NUMERO_COMPTE ); /*==============================================================*/ /* Index: REMISE_FK */ /*==============================================================*/ create index REMISE_FK on REMISE ( ID_CAISSE ); /*==============================================================*/ /* Index: REMISE2_FK */ /*==============================================================*/ create index REMISE2_FK on REMISE ( NUMERO_COMPTE ); /*==============================================================*/ /* Table: SPONSORS */ /*==============================================================*/ create table SPONSORS ( ID_PERSONNE INT4 not null, NOM_OBJET TEXT null, TELEPHONE TEXT null, CATEGORIE TEXT null, constraint PK_SPONSORS primary key (ID_PERSONNE) ); /*==============================================================*/ /* Index: SPONSORS_PK */ /*==============================================================*/ create unique index SPONSORS_PK on SPONSORS ( ID_PERSONNE ); /*==============================================================*/ /* Table: STOCK */ /*==============================================================*/ create table STOCK ( SITE TEXT null, DISPONIBLE NUMERIC null, ALERTE NUMERIC null, ID_STOCK SERIAL not null, ID_OBJET INT4 not null, constraint PK_STOCK primary key (ID_STOCK) ); /*==============================================================*/ /* Index: STOCK_PK */ /*==============================================================*/ create unique index STOCK_PK on STOCK ( ID_STOCK ); /*==============================================================*/ /* Index: REFERENCE_FK */ /*==============================================================*/ create index REFERENCE_FK on STOCK ( ID_OBJET ); alter table ACHAT add constraint FK_ACHAT_ACHAT_PERSONNE foreign key (ID_PERSONNE) references PERSONNE (ID_PERSONNE) on delete restrict on update restrict; alter table ACHAT add constraint FK_ACHAT_ACHAT2_FACTURE foreign key (ID_FACTURE) references FACTURE (ID_FACTURE) on delete restrict on update restrict; alter table ACHAT add constraint FK_ACHAT_ACHAT3_CAISSE foreign key (ID_CAISSE) references CAISSE (ID_CAISSE) on delete restrict on update restrict; alter table ACTIVITE add constraint FK_ACTIVITE_OBJET2_OBJET foreign key (ID_OBJET) references OBJET (ID_OBJET) on delete restrict on update restrict; alter table ACTIVITE add constraint FK_ACTIVITE_PROPOSE_CLUB foreign key (ID_DESTINATAIRE) references CLUB (ID_DESTINATAIRE) on delete restrict on update restrict; alter table ADHERENT add constraint FK_ADHERENT_INSCRIPTI_DEPARTEM foreign key (ID_DEPARTEMENT) references DEPARTEMENT (ID_DEPARTEMENT) on delete restrict on update restrict; alter table ADHERENT add constraint FK_ADHERENT_PERSONNE_PERSONNE foreign key (ID_PERSONNE) references PERSONNE (ID_PERSONNE) on delete restrict on update restrict; alter table CAISSECHEQUE add constraint FK_CAISSECH_CAISSE2_CAISSE foreign key (ID_CAISSE) references CAISSE (ID_CAISSE) on delete restrict on update restrict; alter table CAISSEESPECE add constraint FK_CAISSEES_CAISSE_CAISSE foreign key (ID_CAISSE) references CAISSE (ID_CAISSE) on delete restrict on update restrict; alter table CHEQUEEMIS add constraint FK_CHEQUEEM_DEBIT_COMPTE foreign key (NUMERO_COMPTE) references COMPTE (NUMERO_COMPTE) on delete restrict on update restrict; alter table CHEQUEEMIS add constraint FK_CHEQUEEM_PAYE_DESTINAT foreign key (ID_DESTINATAIRE) references DESTINATAIRE (ID_DESTINATAIRE) on delete restrict on update restrict; alter table CHEQUERECU add constraint FK_CHEQUERE_CONTIENT_CAISSECH foreign key (ID_CAISSE) references CAISSECHEQUE (ID_CAISSE) on delete restrict on update restrict; alter table CHEQUERECU add constraint FK_CHEQUERE_IMPRIME_BANQUE foreign key (ID_BANQUE) references BANQUE (ID_BANQUE) on delete restrict on update restrict; alter table CLUB add constraint FK_CLUB_DESTINATA_DESTINAT foreign key (ID_DESTINATAIRE) references DESTINATAIRE (ID_DESTINATAIRE) on delete restrict on update restrict; alter table COMPTE add constraint FK_COMPTE_APPARTIEN_BANQUE foreign key (ID_BANQUE) references BANQUE (ID_BANQUE) on delete restrict on update restrict; alter table FOURNISSEUR add constraint FK_FOURNISS_DESTINATA_DESTINAT foreign key (ID_DESTINATAIRE) references DESTINATAIRE (ID_DESTINATAIRE) on delete restrict on update restrict; alter table LIVRE add constraint FK_LIVRE_LIVRE_PRODUIT foreign key (ID_OBJET) references PRODUIT (ID_OBJET) on delete restrict on update restrict; alter table LIVRE add constraint FK_LIVRE_LIVRE2_FOURNISS foreign key (ID_DESTINATAIRE) references FOURNISSEUR (ID_DESTINATAIRE) on delete restrict on update restrict; alter table PRODUIT add constraint FK_PRODUIT_OBJET_OBJET foreign key (ID_OBJET) references OBJET (ID_OBJET) on delete restrict on update restrict; alter table QUANTITE add constraint FK_QUANTITE_QUANTITE_FACTURE foreign key (ID_FACTURE) references FACTURE (ID_FACTURE) on delete restrict on update restrict; alter table QUANTITE add constraint FK_QUANTITE_QUANTITE2_OBJET foreign key (ID_OBJET) references OBJET (ID_OBJET) on delete restrict on update restrict; alter table REMISE add constraint FK_REMISE_REMISE_CAISSE foreign key (ID_CAISSE) references CAISSE (ID_CAISSE) on delete restrict on update restrict; alter table REMISE add constraint FK_REMISE_REMISE2_COMPTE foreign key (NUMERO_COMPTE) references COMPTE (NUMERO_COMPTE) on delete restrict on update restrict; alter table SPONSORS add constraint FK_SPONSORS_PERSONNE2_PERSONNE foreign key (ID_PERSONNE) references PERSONNE (ID_PERSONNE) on delete restrict on update restrict; alter table STOCK add constraint FK_STOCK_REFERENCE_PRODUIT foreign key (ID_OBJET) references PRODUIT (ID_OBJET) on delete restrict on update restrict;