1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
| -- *********************************************
-- * SQL PostgreSQL generation
-- *--------------------------------------------
-- * DB-MAIN version: 9.2.0
-- * Generator date: Oct 16 2014
-- * Generation date: Fri Nov 13 21:37:16 2015
-- * LUN file: ~/Projets/Répertoire téléphonique/Répertoire Téléphonique.lun
-- * Schema: RépertoireTéléphonique/SQL
-- *********************************************
-- Database Section
-- ________________
create database RepertoireTelephonique;
-- Tables Section
-- _____________
create table ADRESSE (
AdresseId integer not null,
AdresseRue varchar(65) not null,
AdresseVille varchar(50) not null,
AdresseCodePostal varchar(5) not null,
InscritId integer not null,
CategorieId smallint not null,
constraint ID_ADRESSE primary key (AdresseId));
create table CATEGORIE (
CategorieId smallint not null,
CategorieLibelle varchar(25) not null,
constraint ID_CATEGORIE primary key (CategorieId));
create table CATEGORIE_ADRESSE (
CategorieId smallint not null,
constraint FKCAT_CAT_ID primary key (CategorieId));
create table CATEGORIE_DIVERS (
CategorieId smallint not null,
constraint FKCAT_CAT_1_ID primary key (CategorieId));
create table CATEGORIE_INSCRIT (
CategorieId smallint not null,
constraint FKCAT_CAT_2_ID primary key (CategorieId));
create table COMMENTAIRE (
InscritId integer not null,
CommentaireContenu varchar(255) not null,
constraint FKINS_COM_ID primary key (InscritId));
create table INSCRIT (
InscritId integer not null,
InscritNom varchar(30) not null,
InscritPrenom varchar(20) not null,
InscritDateNaissance date not null,
TitreId smallint not null,
CategorieId smallint not null,
constraint ID_INSCRIT_ID primary key (InscritId));
create table MAIL (
MailId integer not null,
MailAdresse varchar(50) not null,
InscritId integer not null,
CategorieId smallint not null,
constraint ID_MAIL primary key (MailId),
constraint IDMAIL unique (InscritId, MailAdresse));
create table PSEUDO (
PseudoId integer not null,
PseudoLibelle varchar(30) not null,
InscritId integer not null,
constraint ID_PSEUDO primary key (PseudoId),
constraint IDPSEUDO unique (InscritId, PseudoLibelle));
create table SITE (
SiteId integer not null,
SiteUrl varchar(80) not null,
InscritId integer not null,
CategorieId smallint not null,
constraint ID_SITE primary key (SiteId),
constraint SID_SITE unique (SiteUrl));
create table TELEPHONE (
TelephoneId integer not null,
TelephoneNumero varchar(20) not null,
TelephoneType varchar(20) not null,
InscritId integer not null,
CategorieId smallint not null,
constraint ID_TELEPHONE primary key (TelephoneId),
constraint IDTELEPHONE unique (InscritId, TelephoneNumero));
create table TITRE (
TitreId smallint not null,
TitreLibelle varchar(15) not null,
constraint ID_TITRE primary key (TitreId));
-- Constraints Section
-- ___________________
alter table ADRESSE add constraint FKPOSSEDER
foreign key (InscritId)
references INSCRIT;
alter table ADRESSE add constraint FKADR_CAT
foreign key (CategorieId)
references CATEGORIE_ADRESSE;
alter table CATEGORIE_ADRESSE add constraint FKCAT_CAT_FK
foreign key (CategorieId)
references CATEGORIE;
alter table CATEGORIE_DIVERS add constraint FKCAT_CAT_1_FK
foreign key (CategorieId)
references CATEGORIE;
alter table CATEGORIE_INSCRIT add constraint FKCAT_CAT_2_FK
foreign key (CategorieId)
references CATEGORIE;
alter table COMMENTAIRE add constraint FKINS_COM_FK
foreign key (InscritId)
references INSCRIT;
--Not implemented
--alter table INSCRIT add constraint ID_INSCRIT_CHK
-- check(exists(select * from TELEPHONE
-- where TELEPHONE.InscritId = InscritId));
alter table INSCRIT add constraint FKETRE
foreign key (TitreId)
references TITRE;
alter table INSCRIT add constraint FKINS_CAT
foreign key (CategorieId)
references CATEGORIE_INSCRIT;
alter table MAIL add constraint FKAVOIR
foreign key (InscritId)
references INSCRIT;
alter table MAIL add constraint FKMAIL_CAT
foreign key (CategorieId)
references CATEGORIE_DIVERS;
alter table PSEUDO add constraint FKETRE_SURNOMME
foreign key (InscritId)
references INSCRIT;
alter table SITE add constraint FKDISPOSER
foreign key (InscritId)
references INSCRIT;
alter table SITE add constraint FKSITE_CAT
foreign key (CategorieId)
references CATEGORIE_DIVERS;
alter table TELEPHONE add constraint FKDETENIR
foreign key (InscritId)
references INSCRIT;
alter table TELEPHONE add constraint FKTEL_CAT
foreign key (CategorieId)
references CATEGORIE_DIVERS;
-- Index Section
-- _____________ |
Partager