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 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691
| CREATE DATABASE DB_FORUM
GO
USE DB_FORUM
GO
if exists (select 1
from sysindexes
where id = object_id('COLLABORATEUR')
and name = 'APPARTIEN_FK'
and indid > 0
and indid < 255)
drop index COLLABORATEUR.APPARTIEN_FK
go
if exists (select 1
from sysindexes
where id = object_id('COURRIER')
and name = 'ARRIVEE_FK'
and indid > 0
and indid < 255)
drop index COURRIER.ARRIVEE_FK
go
if exists (select 1
from sysindexes
where id = object_id('COURRIER')
and name = 'ARRIVER_FK'
and indid > 0
and indid < 255)
drop index COURRIER.ARRIVER_FK
go
if exists (select 1
from sysindexes
where id = object_id('COURRIER')
and name = 'CREER_FK'
and indid > 0
and indid < 255)
drop index COURRIER.CREER_FK
go
if exists (select 1
from sysindexes
where id = object_id('COURRIER')
and name = 'EST_DE_TYPE_FK'
and indid > 0
and indid < 255)
drop index COURRIER.EST_DE_TYPE_FK
go
if exists (select 1
from sysindexes
where id = object_id('COURRIER')
and name = 'PJ_COURRIER_FK'
and indid > 0
and indid < 255)
drop index COURRIER.PJ_COURRIER_FK
go
if exists (select 1
from sysindexes
where id = object_id('COURRIER_AFFECTE')
and name = 'DEVIENT_FK'
and indid > 0
and indid < 255)
drop index COURRIER_AFFECTE.DEVIENT_FK
go
if exists (select 1
from sysindexes
where id = object_id('ENTITE')
and name = 'CONCERNE_FK'
and indid > 0
and indid < 255)
drop index ENTITE.CONCERNE_FK
go
if exists (select 1
from sysindexes
where id = object_id('ENTITE')
and name = 'ENTITE_SUPERIEUR_FK'
and indid > 0
and indid < 255)
drop index ENTITE.ENTITE_SUPERIEUR_FK
go
if exists (select 1
from sysindexes
where id = object_id('FONCTION')
and name = 'A_LES_FONCTIONS_FK'
and indid > 0
and indid < 255)
drop index FONCTION.A_LES_FONCTIONS_FK
go
if exists (select 1
from sysindexes
where id = object_id('INTERNE')
and name = 'INTERNE2_FK'
and indid > 0
and indid < 255)
drop index INTERNE.INTERNE2_FK
go
if exists (select 1
from sysindexes
where id = object_id('INTERNE')
and name = 'INTERNE_FK'
and indid > 0
and indid < 255)
drop index INTERNE.INTERNE_FK
go
if exists (select 1
from sysindexes
where id = object_id('ORGANISME')
and name = 'EXTERNE1_FK'
and indid > 0
and indid < 255)
drop index ORGANISME.EXTERNE1_FK
go
if exists (select 1
from sysindexes
where id = object_id('PERSONNE_PHYSIQUE')
and name = 'AVOIR_PERSONNE_FK'
and indid > 0
and indid < 255)
drop index PERSONNE_PHYSIQUE.AVOIR_PERSONNE_FK
go
if exists (select 1
from sysindexes
where id = object_id('PERSONNE_PHYSIQUE')
and name = 'EXTERNE_FK'
and indid > 0
and indid < 255)
drop index PERSONNE_PHYSIQUE.EXTERNE_FK
go
if exists (select 1
from sysindexes
where id = object_id('PIECE_JOINTE')
and name = 'PJ_AFFECTATION_FK'
and indid > 0
and indid < 255)
drop index PIECE_JOINTE.PJ_AFFECTATION_FK
go
if exists (select 1
from sysindexes
where id = object_id('TACHE')
and name = 'DELEGUER_FK'
and indid > 0
and indid < 255)
drop index TACHE.DELEGUER_FK
go
if exists (select 1
from sysindexes
where id = object_id('TACHE')
and name = 'PJ_TACHE_FK'
and indid > 0
and indid < 255)
drop index TACHE.PJ_TACHE_FK
go
if exists (select 1
from sysindexes
where id = object_id('TACHE')
and name = 'REATTRIBUER_FK'
and indid > 0
and indid < 255)
drop index TACHE.REATTRIBUER_FK
go
if exists (select 1
from sysindexes
where id = object_id('TACHE')
and name = 'TRAITE_FK'
and indid > 0
and indid < 255)
drop index TACHE.TRAITE_FK
go
if exists (select 1
from sysindexes
where id = object_id('VERSION')
and name = 'DEVIENT_VERSION_FK'
and indid > 0
and indid < 255)
drop index VERSION.DEVIENT_VERSION_FK
go
if exists (select 1
from sysobjects
where id = object_id('COLLABORATEUR')
and type = 'U')
drop table COLLABORATEUR
go
if exists (select 1
from sysobjects
where id = object_id('COURRIER')
and type = 'U')
drop table COURRIER
go
if exists (select 1
from sysobjects
where id = object_id('COURRIER_AFFECTE')
and type = 'U')
drop table COURRIER_AFFECTE
go
if exists (select 1
from sysobjects
where id = object_id('ENTITE')
and type = 'U')
drop table ENTITE
go
if exists (select 1
from sysobjects
where id = object_id('FONCTION')
and type = 'U')
drop table FONCTION
go
if exists (select 1
from sysobjects
where id = object_id('INTERNE')
and type = 'U')
drop table INTERNE
go
if exists (select 1
from sysobjects
where id = object_id('ORGANISME')
and type = 'U')
drop table ORGANISME
go
if exists (select 1
from sysobjects
where id = object_id('PERSONNE_PHYSIQUE')
and type = 'U')
drop table PERSONNE_PHYSIQUE
go
if exists (select 1
from sysobjects
where id = object_id('PIECE_JOINTE')
and type = 'U')
drop table PIECE_JOINTE
go
if exists (select 1
from sysobjects
where id = object_id('TACHE')
and type = 'U')
drop table TACHE
go
if exists (select 1
from sysobjects
where id = object_id('TYPE')
and type = 'U')
drop table TYPE
go
if exists (select 1
from sysobjects
where id = object_id('VERSION')
and type = 'U')
drop table VERSION
go
/*==============================================================*/
/* Table: COLLABORATEUR */
/*==============================================================*/
create table COLLABORATEUR (
ID_COLLABO numeric identity,
ID_ENTITE numeric not null,
NOM_COLLABO text null,
PRENOM_COLLABO text null,
STATUT_COLLABO text null,
NIVEAU int null,
constraint PK_COLLABORATEUR primary key (ID_COLLABO)
)
go
/*==============================================================*/
/* Index: APPARTIEN_FK */
/*==============================================================*/
create index APPARTIEN_FK on COLLABORATEUR (
ID_ENTITE
)
go
/*==============================================================*/
/* Table: COURRIER */
/*==============================================================*/
create table COURRIER (
ID_COURRIER numeric identity,
ID_PERS numeric null,
ID_COLLABO numeric not null,
ID_TYPE2 numeric null,
ID_ORG numeric null,
ID_PJ numeric not null,
DATE_CREATION datetime null,
REFERENCE text null,
NUM_CHRONO text null,
MODE text null,
OBJET text null,
DATE_RECEPTION text null,
COM_CONTENU text null,
SENS_DU_COURRIER numeric null,
NECI_REPONSE bit null,
constraint PK_COURRIER primary key (ID_COURRIER)
)
go
/*==============================================================*/
/* Index: CREER_FK */
/*==============================================================*/
create index CREER_FK on COURRIER (
ID_COLLABO
)
go
/*==============================================================*/
/* Index: PJ_COURRIER_FK */
/*==============================================================*/
create index PJ_COURRIER_FK on COURRIER (
ID_PJ
)
go
/*==============================================================*/
/* Index: EST_DE_TYPE_FK */
/*==============================================================*/
create index EST_DE_TYPE_FK on COURRIER (
ID_TYPE2
)
go
/*==============================================================*/
/* Index: ARRIVER_FK */
/*==============================================================*/
create index ARRIVER_FK on COURRIER (
ID_PERS
)
go
/*==============================================================*/
/* Index: ARRIVEE_FK */
/*==============================================================*/
create index ARRIVEE_FK on COURRIER (
ID_ORG
)
go
/*==============================================================*/
/* Table: COURRIER_AFFECTE */
/*==============================================================*/
create table COURRIER_AFFECTE (
ID_AFFECT numeric identity,
ID_COURRIER numeric not null,
COM_DE_RETOUR text null,
CONFIDENTIALITE bit null,
DATE_DER_ALERT datetime null,
DATE_RECEP datetime null,
RETOUR bit null,
ETAT_COU text null,
constraint PK_COURRIER_AFFECTE primary key (ID_AFFECT)
)
go
/*==============================================================*/
/* Index: DEVIENT_FK */
/*==============================================================*/
create index DEVIENT_FK on COURRIER_AFFECTE (
ID_COURRIER
)
go
/*==============================================================*/
/* Table: ENTITE */
/*==============================================================*/
create table ENTITE (
ID_ENTITE numeric identity,
ENT_ID_ENTITE numeric null,
ID_TYPE2 numeric null,
NOM_ENTITE text null,
DESC_ENTITE text null,
ABREVIATION text null,
constraint PK_ENTITE primary key (ID_ENTITE)
)
go
/*==============================================================*/
/* Index: ENTITE_SUPERIEUR_FK */
/*==============================================================*/
create index ENTITE_SUPERIEUR_FK on ENTITE (
ENT_ID_ENTITE
)
go
/*==============================================================*/
/* Index: CONCERNE_FK */
/*==============================================================*/
create index CONCERNE_FK on ENTITE (
ID_TYPE2
)
go
/*==============================================================*/
/* Table: FONCTION */
/*==============================================================*/
create table FONCTION (
ID_FONCTION numeric identity,
ID_COLLABO numeric null,
NOM_FONCTION text null,
constraint PK_FONCTION primary key (ID_FONCTION)
)
go
/*==============================================================*/
/* Index: A_LES_FONCTIONS_FK */
/*==============================================================*/
create index A_LES_FONCTIONS_FK on FONCTION (
ID_COLLABO
)
go
/*==============================================================*/
/* Table: INTERNE */
/*==============================================================*/
create table INTERNE (
ID_VERSION numeric not null,
ID_ENTITE numeric not null,
constraint PK_INTERNE primary key (ID_VERSION, ID_ENTITE)
)
go
/*==============================================================*/
/* Index: INTERNE_FK */
/*==============================================================*/
create index INTERNE_FK on INTERNE (
ID_VERSION
)
go
/*==============================================================*/
/* Index: INTERNE2_FK */
/*==============================================================*/
create index INTERNE2_FK on INTERNE (
ID_ENTITE
)
go
/*==============================================================*/
/* Table: ORGANISME */
/*==============================================================*/
create table ORGANISME (
ID_ORG numeric identity,
ID_VERSION numeric null,
RAISON_ORG text null,
ADRESSE_ORG text null,
TEL_ORG text null,
constraint PK_ORGANISME primary key (ID_ORG)
)
go
/*==============================================================*/
/* Index: EXTERNE1_FK */
/*==============================================================*/
create index EXTERNE1_FK on ORGANISME (
ID_VERSION
)
go
/*==============================================================*/
/* Table: PERSONNE_PHYSIQUE */
/*==============================================================*/
create table PERSONNE_PHYSIQUE (
ID_PERS numeric not null,
ID_ORG numeric null,
ID_VERSION numeric null,
NOM_PERS text null,
PRENOM_PER text null,
EMAIL_PERS text null,
PROFESSION text null,
TEL_PERS text null,
constraint PK_PERSONNE_PHYSIQUE primary key (ID_PERS)
)
go
/*==============================================================*/
/* Index: AVOIR_PERSONNE_FK */
/*==============================================================*/
create index AVOIR_PERSONNE_FK on PERSONNE_PHYSIQUE (
ID_ORG
)
go
/*==============================================================*/
/* Index: EXTERNE_FK */
/*==============================================================*/
create index EXTERNE_FK on PERSONNE_PHYSIQUE (
ID_VERSION
)
go
/*==============================================================*/
/* Table: PIECE_JOINTE */
/*==============================================================*/
create table PIECE_JOINTE (
ID_PJ numeric identity,
ID_AFFECT numeric null,
NOM_PJ text null,
EMPLACEMENT text null,
constraint PK_PIECE_JOINTE primary key (ID_PJ)
)
go
/*==============================================================*/
/* Index: PJ_AFFECTATION_FK */
/*==============================================================*/
create index PJ_AFFECTATION_FK on PIECE_JOINTE (
ID_AFFECT
)
go
/*==============================================================*/
/* Table: TACHE */
/*==============================================================*/
create table TACHE (
ID_TACHE numeric identity,
ID_PJ numeric null,
ID_COLLABO numeric not null,
ID_AFFECT numeric not null,
TAC_ID_TACHE numeric null,
COMMEN_TACHE text null,
DATE_REC_TACHE datetime null,
DTE_DER_ALERT datetime null,
DELAI_TACHE numeric null,
COM_DE_RETOUR text null,
ETAT_TACH numeric null,
constraint PK_TACHE primary key (ID_TACHE)
)
go
/*==============================================================*/
/* Index: REATTRIBUER_FK */
/*==============================================================*/
create index REATTRIBUER_FK on TACHE (
TAC_ID_TACHE
)
go
/*==============================================================*/
/* Index: PJ_TACHE_FK */
/*==============================================================*/
create index PJ_TACHE_FK on TACHE (
ID_PJ
)
go
/*==============================================================*/
/* Index: TRAITE_FK */
/*==============================================================*/
create index TRAITE_FK on TACHE (
ID_COLLABO
)
go
/*==============================================================*/
/* Index: DELEGUER_FK */
/*==============================================================*/
create index DELEGUER_FK on TACHE (
ID_AFFECT
)
go
/*==============================================================*/
/* Table: TYPE */
/*==============================================================*/
create table TYPE (
ID_TYPE2 numeric identity,
DESC_TYPE text null,
DELAI_TYPE bigint null,
NOM_TYPE text null,
NIVEAU_SIGNATAIRE numeric null,
NIVEAU_APPROBATEUR numeric null,
constraint PK_TYPE primary key (ID_TYPE2)
)
go
/*==============================================================*/
/* Table: VERSION */
/*==============================================================*/
create table VERSION (
ID_VERSION numeric identity,
ID_COURRIER numeric not null,
NUM_VERSION int null,
OBJET_CD text null,
DT_EMI datetime null,
CONTENU text null,
DT_MODIF datetime null,
constraint PK_VERSION primary key(ID_VERSION)
)
go
/*==============================================================*/
/* Index: DEVIENT_VERSION_FK */
/*==============================================================*/
create index DEVIENT_VERSION_FK on VERSION (
ID_COURRIER
)
go
alter table COLLABORATEUR
add constraint FK_COLLABOR_APPARTIEN_ENTITE foreign key (ID_ENTITE)
references ENTITE (ID_ENTITE)
go
alter table COURRIER
add constraint FK_COURRIER_ARRIVEE_ORGANISM foreign key (ID_ORG)
references ORGANISME (ID_ORG)
go
alter table COURRIER
add constraint FK_COURRIER_ARRIVER_PERSONNE foreign key (ID_PERS)
references PERSONNE_PHYSIQUE (ID_PERS)
go
alter table COURRIER
add constraint FK_COURRIER_CREER_COLLABOR foreign key (ID_COLLABO)
references COLLABORATEUR (ID_COLLABO)
go
alter table COURRIER
add constraint FK_COURRIER_EST_DE_TY_TYPE foreign key (ID_TYPE2)
references TYPE (ID_TYPE2)
go
alter table COURRIER
add constraint FK_COURRIER_PJ_COURRI_PIECE_JO foreign key (ID_PJ)
references PIECE_JOINTE (ID_PJ)
go
alter table COURRIER_AFFECTE
add constraint FK_COURRIER_DEVIENT_COURRIER foreign key (ID_COURRIER)
references COURRIER (ID_COURRIER)
go
alter table ENTITE
add constraint FK_ENTITE_CONCERNE_TYPE foreign key (ID_TYPE2)
references TYPE (ID_TYPE2)
go
alter table ENTITE
add constraint FK_ENTITE_ENTITE_SU_ENTITE foreign key (ENT_ID_ENTITE)
references ENTITE (ID_ENTITE)
go
alter table FONCTION
add constraint FK_FONCTION_A_LES_FON_COLLABOR foreign key (ID_COLLABO)
references COLLABORATEUR (ID_COLLABO)
go
alter table INTERNE
add constraint FK_INTERNE_INTERNE_VERSION foreign key (ID_VERSION)
references VERSION (ID_VERSION)
go
alter table INTERNE
add constraint FK_INTERNE_INTERNE2_ENTITE foreign key (ID_ENTITE)
references ENTITE (ID_ENTITE)
go
alter table ORGANISME
add constraint FK_ORGANISM_EXTERNE1_VERSION foreign key (ID_VERSION)
references VERSION (ID_VERSION)
go
alter table PERSONNE_PHYSIQUE
add constraint FK_PERSONNE_AVOIR_PER_ORGANISM foreign key (ID_ORG)
references ORGANISME (ID_ORG)
go
alter table PERSONNE_PHYSIQUE
add constraint FK_PERSONNE_EXTERNE_VERSION foreign key (ID_VERSION)
references VERSION (ID_VERSION)
go
alter table PIECE_JOINTE
add constraint FK_PIECE_JO_PJ_AFFECT_COURRIER foreign key (ID_AFFECT)
references COURRIER_AFFECTE (ID_AFFECT)
go
alter table TACHE
add constraint FK_TACHE_DELEGUER_COURRIER foreign key (ID_AFFECT)
references COURRIER_AFFECTE (ID_AFFECT)
go
alter table TACHE
add constraint FK_TACHE_PJ_TACHE_PIECE_JO foreign key (ID_PJ)
references PIECE_JOINTE (ID_PJ)
go
alter table TACHE
add constraint FK_TACHE_REATTRIBU_TACHE foreign key (TAC_ID_TACHE)
references TACHE (ID_TACHE)
go
alter table TACHE
add constraint FK_TACHE_TRAITE_COLLABOR foreign key (ID_COLLABO)
references COLLABORATEUR (ID_COLLABO)
go
alter table VERSION
add constraint FK_VERSION_DEVIENT_V_COURRIER foreign key (ID_COURRIER)
references COURRIER (ID_COURRIER)
go |