-
Notifications
You must be signed in to change notification settings - Fork 0
/
SopraBD-2016-01-11.sql
307 lines (247 loc) · 9.36 KB
/
SopraBD-2016-01-11.sql
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
-- phpMyAdmin SQL Dump
-- version 3.4.11.1deb2+deb7u2
-- http://www.phpmyadmin.net
--
-- Client: localhost
-- Généré le: Lun 11 Janvier 2016 à 00:59
-- Version du serveur: 5.5.46
-- Version de PHP: 5.4.4-14+deb7u5
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Base de données: `SopraBD`
--
-- --------------------------------------------------------
--
-- Structure de la table `Equipments`
--
CREATE TABLE IF NOT EXISTS `Equipments` (
`equipmentID` int(3) unsigned NOT NULL AUTO_INCREMENT,
`description` text COLLATE utf8_unicode_ci,
PRIMARY KEY (`equipmentID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=5 ;
--
-- Contenu de la table `Equipments`
--
INSERT INTO `Equipments` (`equipmentID`, `description`) VALUES
(1, 'Visio'),
(2, 'Téléphone'),
(3, 'Salle Digilab'),
(4, 'Sécurisée');
-- --------------------------------------------------------
--
-- Structure de la table `InvitedUsers`
--
CREATE TABLE IF NOT EXISTS `InvitedUsers` (
`invitedUserID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`reservationRef` int(10) unsigned NOT NULL,
`userRef` int(10) unsigned NOT NULL,
PRIMARY KEY (`invitedUserID`),
KEY `userRef` (`userRef`),
KEY `reservationRef` (`reservationRef`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Structure de la table `OldInvitedUsers`
--
CREATE TABLE IF NOT EXISTS `OldInvitedUsers` (
`oldInvitedUserID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`oldReservationRef` int(12) unsigned NOT NULL,
`userRef` int(10) unsigned NOT NULL,
PRIMARY KEY (`oldInvitedUserID`),
KEY `oldReservationRef` (`oldReservationRef`),
KEY `oldInvitedUserID` (`userRef`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Structure de la table `OldReservations`
--
CREATE TABLE IF NOT EXISTS `OldReservations` (
`oldReservationID` int(12) unsigned NOT NULL AUTO_INCREMENT,
`roomRef` int(10) unsigned NOT NULL,
`start` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`end` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`ownerRef` int(10) unsigned NOT NULL,
PRIMARY KEY (`oldReservationID`),
KEY `roomRef` (`roomRef`),
KEY `ownerRef` (`ownerRef`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=5 ;
--
-- Contenu de la table `OldReservations`
--
INSERT INTO `OldReservations` (`oldReservationID`, `roomRef`, `start`, `end`, `ownerRef`) VALUES
(1, 2, '2016-01-14 14:30:00', '2016-01-14 15:00:00', 15),
(2, 1, '2015-12-07 11:18:54', '2015-12-11 10:20:54', 1),
(3, 3, '2015-12-22 09:00:00', '2015-12-22 13:00:00', 1);
-- --------------------------------------------------------
--
-- Structure de la table `Reservations`
--
CREATE TABLE IF NOT EXISTS `Reservations` (
`reservationID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`roomRef` int(5) unsigned NOT NULL,
`start` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`end` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`ownerRef` int(10) unsigned NOT NULL,
PRIMARY KEY (`reservationID`),
KEY `roomRef` (`roomRef`),
KEY `ownerRef` (`ownerRef`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=4 ;
--
-- Contenu de la table `Reservations`
--
INSERT INTO `Reservations` (`reservationID`, `roomRef`, `start`, `end`, `ownerRef`) VALUES
(3, 1, '2016-01-10 22:13:49', '2016-01-22 17:10:00', 6);
-- --------------------------------------------------------
--
-- Structure de la table `RoomEquipments`
--
CREATE TABLE IF NOT EXISTS `RoomEquipments` (
`roomEquipmentID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`roomRef` int(5) unsigned NOT NULL,
`equipmentRef` int(3) unsigned NOT NULL,
PRIMARY KEY (`roomEquipmentID`),
KEY `roomRef` (`roomRef`),
KEY `equipmentRef` (`equipmentRef`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=7 ;
--
-- Contenu de la table `RoomEquipments`
--
INSERT INTO `RoomEquipments` (`roomEquipmentID`, `roomRef`, `equipmentRef`) VALUES
(1, 1, 1),
(2, 1, 2),
(3, 2, 4),
(4, 3, 3),
(5, 3, 1),
(6, 3, 2);
-- --------------------------------------------------------
--
-- Structure de la table `Rooms`
--
CREATE TABLE IF NOT EXISTS `Rooms` (
`roomID` int(5) unsigned NOT NULL AUTO_INCREMENT,
`siteRef` int(4) unsigned NOT NULL,
`number` text COLLATE utf8_unicode_ci NOT NULL,
`capacity` smallint(4) NOT NULL,
PRIMARY KEY (`roomID`),
KEY `siteRef` (`siteRef`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=4 ;
--
-- Contenu de la table `Rooms`
--
INSERT INTO `Rooms` (`roomID`, `siteRef`, `number`, `capacity`) VALUES
(1, 1, 'Salle Fourier', 60),
(2, 1, 'Salle 102', 30),
(3, 2, 'Salle 3', 3);
-- --------------------------------------------------------
--
-- Structure de la table `Sites`
--
CREATE TABLE IF NOT EXISTS `Sites` (
`siteID` int(4) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`address` text COLLATE utf8_unicode_ci NOT NULL,
`description` text COLLATE utf8_unicode_ci,
PRIMARY KEY (`siteID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=3 ;
--
-- Contenu de la table `Sites`
--
INSERT INTO `Sites` (`siteID`, `name`, `address`, `description`) VALUES
(1, 'INSA Toulouse', 'Avenue de Rangueil', 'Le meilleur endroit du monde'),
(2, 'GEI', 'Impasse de l''informatique', NULL);
-- --------------------------------------------------------
--
-- Structure de la table `test`
--
CREATE TABLE IF NOT EXISTS `test` (
`name` varchar(8) NOT NULL,
`age` int(8) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Contenu de la table `test`
--
INSERT INTO `test` (`name`, `age`) VALUES
('jr', 0),
('jack', 21),
('name', 25);
-- --------------------------------------------------------
--
-- Structure de la table `Users`
--
CREATE TABLE IF NOT EXISTS `Users` (
`userID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`surname` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`mailAddress` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`password` text COLLATE utf8_unicode_ci NOT NULL,
`admin` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`userID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=21 ;
--
-- Contenu de la table `Users`
--
INSERT INTO `Users` (`userID`, `name`, `surname`, `mailAddress`, `password`, `admin`) VALUES
(1, 'Le Botlan', 'Didier', '[email protected]', 'pizza', 1),
(3, 'testUser', 'test', '[email protected]', 'a', 1),
(5, 'Donald', 'Dodo', '[email protected]', 'coincoin', 0),
(6, 'Marre', 'Daniel', '[email protected]', 'marre', 0),
(7, 'lala', 'lili', '[email protected]', 'lala', 0),
(14, 'rgautier', 'rgautier', '[email protected]', 'rgautier', 1),
(15, 'Machin', 'Truc', '[email protected]', 'mc', 0),
(17, 'root', 'admin', '[email protected]', 'adminadmin', 1),
(20, 'Bertin', 'Alexis', '[email protected]', 'alexis', 1);
--
-- Contraintes pour les tables exportées
--
--
-- Contraintes pour la table `InvitedUsers`
--
ALTER TABLE `InvitedUsers`
ADD CONSTRAINT `InvitedUsers_ibfk_1` FOREIGN KEY (`reservationRef`) REFERENCES `Reservations` (`reservationID`),
ADD CONSTRAINT `InvitedUsers_ibfk_2` FOREIGN KEY (`userRef`) REFERENCES `Users` (`userID`);
--
-- Contraintes pour la table `OldInvitedUsers`
--
ALTER TABLE `OldInvitedUsers`
ADD CONSTRAINT `OldInvitedUsers_ibfk_1` FOREIGN KEY (`oldReservationRef`) REFERENCES `OldReservations` (`oldReservationID`),
ADD CONSTRAINT `OldInvitedUsers_ibfk_2` FOREIGN KEY (`userRef`) REFERENCES `Users` (`userID`);
--
-- Contraintes pour la table `OldReservations`
--
ALTER TABLE `OldReservations`
ADD CONSTRAINT `OldReservations_ibfk_1` FOREIGN KEY (`roomRef`) REFERENCES `Rooms` (`roomID`),
ADD CONSTRAINT `OldReservations_ibfk_2` FOREIGN KEY (`ownerRef`) REFERENCES `Users` (`userID`);
--
-- Contraintes pour la table `Reservations`
--
ALTER TABLE `Reservations`
ADD CONSTRAINT `Reservations_ibfk_1` FOREIGN KEY (`roomRef`) REFERENCES `Rooms` (`roomID`),
ADD CONSTRAINT `Reservations_ibfk_2` FOREIGN KEY (`ownerRef`) REFERENCES `Users` (`userID`);
--
-- Contraintes pour la table `RoomEquipments`
--
ALTER TABLE `RoomEquipments`
ADD CONSTRAINT `RoomEquipments_ibfk_1` FOREIGN KEY (`roomRef`) REFERENCES `Rooms` (`roomID`),
ADD CONSTRAINT `RoomEquipments_ibfk_2` FOREIGN KEY (`equipmentRef`) REFERENCES `Equipments` (`equipmentID`);
--
-- Contraintes pour la table `Rooms`
--
ALTER TABLE `Rooms`
ADD CONSTRAINT `Rooms_ibfk_1` FOREIGN KEY (`siteRef`) REFERENCES `Sites` (`siteID`);
DELIMITER $$
--
-- Événements
--
CREATE DEFINER=`root`@`localhost` EVENT `deleteOldReservation` ON SCHEDULE EVERY 1 DAY STARTS '2016-01-10 22:37:23' ON COMPLETION NOT PRESERVE ENABLE DO INSERT INTO `OldReservations`(`oldReservationID`, `roomRef`, `start`, `end`, `ownerRef`)
SELECT null, `roomRef`, `start`, `end`, `ownerRef`
FROM `Reservations`
WHERE end < NOW()$$
DELIMITER ;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;