· 7 years ago · Jan 04, 2019, 05:20 AM
1/*==============================================================*/
2/* Nom de SGBD : MySQL 4.0 */
3/* Date de création : 08/10/2012 09:01:58 */
4/*==============================================================*/
5
6
7drop index ARRIVE_A_FK on LIAISON;
8
9drop index PAR_DE_FK on LIAISON;
10
11drop index CONCERNE_FK on RESERVATION;
12
13drop index FAIT_FK on RESERVATION;
14
15drop index EFFECTUE_FK on TRAJET;
16
17drop index PARCOURS_FK on TRAJET;
18
19drop table if exists LIAISON;
20
21drop table if exists RESERVATION;
22
23drop table if exists TRAIN;
24
25drop table if exists TRAJET;
26
27drop table if exists USER;
28
29drop table if exists VILLE;
30
31/*==============================================================*/
32/* Table : LIAISON */
33/*==============================================================*/
34create table LIAISON
35(
36 LIAISON_ID int not null,
37 VILLE_DEPART_ID int not null,
38 VILLE_ARRIVEE_ID int not null,
39 LONGUEUR int,
40 primary key (LIAISON_ID)
41)
42type = InnoDB;
43
44/*==============================================================*/
45/* Index : PAR_DE_FK */
46/*==============================================================*/
47create index PAR_DE_FK on LIAISON
48(
49 VILLE_DEPART_ID
50);
51
52/*==============================================================*/
53/* Index : ARRIVE_A_FK */
54/*==============================================================*/
55create index ARRIVE_A_FK on LIAISON
56(
57 VILLE_ARRIVEE_ID
58);
59
60/*==============================================================*/
61/* Table : RESERVATION */
62/*==============================================================*/
63create table RESERVATION
64(
65 RESERVATION_ID int not null,
66 TAJET_ID int not null,
67 USER_ID int not null,
68 primary key (RESERVATION_ID)
69)
70type = InnoDB;
71
72/*==============================================================*/
73/* Index : CONCERNE_FK */
74/*==============================================================*/
75create index CONCERNE_FK on RESERVATION
76(
77 TAJET_ID
78);
79
80/*==============================================================*/
81/* Index : FAIT_FK */
82/*==============================================================*/
83create index FAIT_FK on RESERVATION
84(
85 USER_ID
86);
87
88/*==============================================================*/
89/* Table : TRAIN */
90/*==============================================================*/
91create table TRAIN
92(
93 TRAIN_ID int not null,
94 NB_PLACES int,
95 VITESSE int,
96 primary key (TRAIN_ID)
97)
98type = InnoDB;
99
100/*==============================================================*/
101/* Table : TRAJET */
102/*==============================================================*/
103create table TRAJET
104(
105 TAJET_ID int not null,
106 TRAIN_ID int not null,
107 LIAISON_ID int not null,
108 HEURE_DEPART time,
109 primary key (TAJET_ID)
110)
111type = InnoDB;
112
113/*==============================================================*/
114/* Index : PARCOURS_FK */
115/*==============================================================*/
116create index PARCOURS_FK on TRAJET
117(
118 TRAIN_ID
119);
120
121/*==============================================================*/
122/* Index : EFFECTUE_FK */
123/*==============================================================*/
124create index EFFECTUE_FK on TRAJET
125(
126 LIAISON_ID
127);
128
129/*==============================================================*/
130/* Table : USER */
131/*==============================================================*/
132create table USER
133(
134 USER_ID int not null,
135 LOGIN text,
136 PASSWORD text,
137 primary key (USER_ID)
138)
139type = InnoDB;
140
141/*==============================================================*/
142/* Table : VILLE */
143/*==============================================================*/
144create table VILLE
145(
146 VILLE_ID int not null,
147 NOM text,
148 primary key (VILLE_ID)
149)
150type = InnoDB;
151
152alter table LIAISON add constraint FK_ARRIVE_A foreign key (VILLE_ARRIVEE_ID)
153 references VILLE (VILLE_ID) on delete cascade on update restrict;
154
155alter table LIAISON add constraint FK_PAR_DE foreign key (VILLE_DEPART_ID)
156 references VILLE (VILLE_ID) on delete cascade on update restrict;
157
158alter table RESERVATION add constraint FK_CONCERNE foreign key (TAJET_ID)
159 references TRAJET (TAJET_ID) on delete cascade on update restrict;
160
161alter table RESERVATION add constraint FK_FAIT foreign key (USER_ID)
162 references USER (USER_ID) on delete cascade on update restrict;
163
164alter table TRAJET add constraint FK_EFFECTUE foreign key (LIAISON_ID)
165 references LIAISON (LIAISON_ID) on delete cascade on update restrict;
166
167alter table TRAJET add constraint FK_PARCOURS foreign key (TRAIN_ID)
168 references TRAIN (TRAIN_ID) on delete cascade on update restrict;