· 6 years ago · Jan 31, 2020, 11:53 AM
1/*==============================================================*/
2/* Nom de SGBD : Microsoft SQL Server 2000 */
3/* Date de cr�ation : 29/01/2020 23:07:50 */
4/*==============================================================*/
5
6
7if exists (select 1
8 from dbo.sysreferences r join dbo.sysobjects o on (o.id = r.constid and o.type = 'F')
9 where r.fkeyid = object_id('ARTICLES') and o.name = 'FK_ARTICLES_CONTIEN_DEMANDE')
10alter table ARTICLES
11 drop constraint FK_ARTICLES_CONTIEN_DEMANDE
12go
13
14if exists (select 1
15 from dbo.sysreferences r join dbo.sysobjects o on (o.id = r.constid and o.type = 'F')
16 where r.fkeyid = object_id('DEMANDE') and o.name = 'FK_DEMANDE_FAIT_UTULISAT')
17alter table DEMANDE
18 drop constraint FK_DEMANDE_FAIT_UTULISAT
19go
20
21if exists (select 1
22 from dbo.sysreferences r join dbo.sysobjects o on (o.id = r.constid and o.type = 'F')
23 where r.fkeyid = object_id('UTULISATEUR') and o.name = 'FK_UTULISAT_APPARTIEN_SERVICES')
24alter table UTULISATEUR
25 drop constraint FK_UTULISAT_APPARTIEN_SERVICES
26go
27
28if exists (select 1
29 from sysobjects
30 where id = object_id('ARTICLES')
31 and type = 'U')
32 drop table ARTICLES
33go
34
35if exists (select 1
36 from sysobjects
37 where id = object_id('DEMANDE')
38 and type = 'U')
39 drop table DEMANDE
40go
41
42if exists (select 1
43 from sysobjects
44 where id = object_id('SERVICES')
45 and type = 'U')
46 drop table SERVICES
47go
48
49if exists (select 1
50 from sysobjects
51 where id = object_id('UTULISATEUR')
52 and type = 'U')
53 drop table UTULISATEUR
54go
55
56/*==============================================================*/
57/* Table : ARTICLES */
58/*==============================================================*/
59create table ARTICLES (
60 _ID_ARTI int not null,
61 ID_DEM int null,
62 NOM_ text not null,
63 QTE int not null,
64 QTE_MIN int not null,
65 TYPE text not null,
66 constraint PK_ARTICLES primary key nonclustered (_ID_ARTI)
67)
68go
69
70/*==============================================================*/
71/* Table : DEMANDE */
72/*==============================================================*/
73create table DEMANDE (
74 ID_DEM int not null,
75 ID_USER int not null,
76 QTE_DEM int not null,
77 DATE_COMMANDE datetime not null,
78 ID_UILISATEUR int not null,
79 ID_ARTICLE int not null,
80 constraint PK_DEMANDE primary key nonclustered (ID_DEM)
81)
82go
83
84/*==============================================================*/
85/* Table : SERVICES */
86/*==============================================================*/
87create table SERVICES (
88 _ID_SERV int not null,
89 NOM_SERV text not null,
90 ID_CHEF int not null,
91 constraint PK_SERVICES primary key nonclustered (_ID_SERV)
92)
93go
94
95/*==============================================================*/
96/* Table : UTULISATEUR */
97/*==============================================================*/
98create table UTULISATEUR (
99 ID_USER int not null,
100 _ID_SERV int not null,
101 ID_SERVICE int null,
102 NOM_ text null,
103 PRENOM text null,
104 USERNAME text null,
105 PASSWORD text null,
106 ADMIN bit null,
107 constraint PK_UTULISATEUR primary key nonclustered (ID_USER)
108)
109go
110
111alter table ARTICLES
112 add constraint FK_ARTICLES_CONTIEN_DEMANDE foreign key (ID_DEM)
113 references DEMANDE (ID_DEM)
114go
115
116alter table DEMANDE
117 add constraint FK_DEMANDE_FAIT_UTULISAT foreign key (ID_USER)
118 references UTULISATEUR (ID_USER)
119go
120
121alter table UTULISATEUR
122 add constraint FK_UTULISAT_APPARTIEN_SERVICES foreign key (_ID_SERV)
123 references SERVICES (_ID_SERV)
124go