-
Notifications
You must be signed in to change notification settings - Fork 0
/
MySQL_create_eanprod.sql
465 lines (400 loc) · 14 KB
/
MySQL_create_eanprod.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
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
########################################################
## MySQL_create_eanprod.sql v2.4 ##
## SCRIPT TO GENERATE EAN DATABASE IN MYSQL ENGINE ##
## BE CAREFUL AS IT WILL ERASE THE EXISTING DATABASE ##
## YOU CAN USE SECTIONS OF IT TO RE-CREATE TABLES ##
## WILL CREATE USER: eanuser / expedia ##
## table names are lowercase so it will work in all ##
## platforms the same. ##
########################################################
## DROP DATABASE IF EXISTS eanprod;
## specify utf8 / ut8_unicode_ci to manage all languages properly
## updated from files contain those characters
## CREATE DATABASE eanprod CHARACTER SET utf8 COLLATE utf8_unicode_ci;
## users permisions
## GRANT ALL ON eanprod.* TO 'eanuser'@'%' IDENTIFIED BY 'Passw@rd1';
## GRANT ALL ON eanprod.* TO 'eanuser'@'localhost' IDENTIFIED BY 'Passw@rd1';
## REQUIRED IN WINDOWS as we do not use STRICT_TRANS_TABLE for the upload process
SET @@global.sql_mode= '';
USE eanprod;
########################################################
## ##
## TABLES CREATED FROM THE EAN RELATIONAL DOWNLOADED ##
## FILES. ##
## ##
########################################################
DROP TABLE IF EXISTS airportcoordinateslist;
CREATE TABLE airportcoordinateslist
(
AirportID INT NOT NULL,
AirportCode VARCHAR(3) NOT NULL,
AirportName VARCHAR(70),
Latitude numeric(9,6),
Longitude numeric(9,6),
MainCityID INT,
CountryCode VARCHAR(2),
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (AirportCode)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
## index by Airport Name to use for text searches
CREATE INDEX idx_airportcoordinatelist_airportname ON airportcoordinateslist(AirportName);
## index by MainCityID to use as relational key
CREATE INDEX idx_airportcoordinatelist_maincityid ON airportcoordinateslist(MainCityID);
DROP TABLE IF EXISTS activepropertylist;
CREATE TABLE activepropertylist
(
EANHotelID INT NOT NULL,
SequenceNumber INT,
Name VARCHAR(70),
Address1 VARCHAR(50),
Address2 VARCHAR(50),
City VARCHAR(50),
StateProvince VARCHAR(2),
PostalCode VARCHAR(15),
Country VARCHAR(2),
Latitude numeric(8,5),
Longitude numeric(8,5),
AirportCode VARCHAR(3),
PropertyCategory INT,
PropertyCurrency VARCHAR(3),
StarRating numeric(2,1),
Confidence INT,
SupplierType VARCHAR(3),
Location VARCHAR(80),
ChainCodeID VARCHAR(5),
RegionID INT,
HighRate numeric(19,4),
LowRate numeric(19,4),
CheckInTime VARCHAR(10),
CheckOutTime VARCHAR(10),
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (EANHotelID)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
DROP TABLE IF EXISTS pointsofinterestcoordinateslist;
CREATE TABLE pointsofinterestcoordinateslist
(
RegionID INT NOT NULL,
RegionName VARCHAR(255),
## as it will be the key need to be less than 767 bytes (767 / 4 = 191.75)
RegionNameLong VARCHAR(191),
Latitude numeric(9,6),
Longitude numeric(9,6),
SubClassification VARCHAR(20),
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (RegionNameLong)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
## index by RegionID to use as relational key
CREATE INDEX idx_pointsofinterestcoordinateslist_regionid ON pointsofinterestcoordinateslist(RegionID);
DROP TABLE IF EXISTS countrylist;
CREATE TABLE countrylist
(
CountryID INT NOT NULL,
LanguageCode VARCHAR(5),
CountryName VARCHAR(255),
CountryCode VARCHAR(2) NOT NULL,
Transliteration VARCHAR(256),
ContinentID INT,
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (CountryID)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
## add indexes by country code & country name
CREATE INDEX idx_countrylist_countrycode ON countrylist(CountryCode);
CREATE INDEX idx_countrylist_countryname ON countrylist(CountryName);
DROP TABLE IF EXISTS propertytypelist;
CREATE TABLE propertytypelist
(
PropertyCategory INT NOT NULL,
LanguageCode VARCHAR(5),
PropertyCategoryDesc VARCHAR(256),
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (PropertyCategory)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
DROP TABLE IF EXISTS chainlist;
CREATE TABLE chainlist
(
ChainCodeID INT NOT NULL,
ChainName VARCHAR(30),
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (ChainCodeID)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
DROP TABLE IF EXISTS propertydescriptionlist;
CREATE TABLE propertydescriptionlist
(
EANHotelID INT NOT NULL,
LanguageCode VARCHAR(5),
PropertyDescription TEXT,
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (EANHotelID)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
DROP TABLE IF EXISTS policydescriptionlist;
CREATE TABLE policydescriptionlist
(
EANHotelID INT NOT NULL,
LanguageCode VARCHAR(5),
PolicyDescription TEXT,
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (EANHotelID)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
DROP TABLE IF EXISTS recreationdescriptionlist;
CREATE TABLE recreationdescriptionlist
(
EANHotelID INT NOT NULL,
LanguageCode VARCHAR(5),
RecreationDescription TEXT,
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (EANHotelID)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
DROP TABLE IF EXISTS areaattractionslist;
CREATE TABLE areaattractionslist
(
EANHotelID INT NOT NULL,
LanguageCode VARCHAR(5),
AreaAttractions TEXT,
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (EANHotelID)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
DROP TABLE IF EXISTS diningdescriptionlist;
CREATE TABLE diningdescriptionlist
(
EANHotelID INT NOT NULL,
LanguageCode VARCHAR(5),
DiningDescription TEXT,
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (EANHotelID)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
DROP TABLE IF EXISTS spadescriptionlist;
CREATE TABLE spadescriptionlist
(
EANHotelID INT NOT NULL,
LanguageCode VARCHAR(5),
SpaDescription TEXT,
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (EANHotelID)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
DROP TABLE IF EXISTS whattoexpectlist;
CREATE TABLE whattoexpectlist
(
EANHotelID INT NOT NULL,
LanguageCode VARCHAR(5),
WhatToExpect TEXT,
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (EANHotelID)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
## Multiple rooms per each hotel - so a compound primary key
DROP TABLE IF EXISTS roomtypelist;
CREATE TABLE roomtypelist
(
EANHotelID INT NOT NULL,
RoomTypeID INT NOT NULL,
LanguageCode VARCHAR(5),
RoomTypeImage VARCHAR(256),
RoomTypeName VARCHAR(200),
RoomTypeDescription TEXT,
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (EANHotelID, RoomTypeID)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
DROP TABLE IF EXISTS attributelist;
CREATE TABLE attributelist
(
AttributeID INT NOT NULL,
LanguageCode VARCHAR(5),
AttributeDesc VARCHAR(255),
Type VARCHAR(15),
SubType VARCHAR(15),
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (AttributeID)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
DROP TABLE IF EXISTS propertyattributelink;
CREATE TABLE propertyattributelink
(
EANHotelID INT NOT NULL,
AttributeID INT NOT NULL,
LanguageCode VARCHAR(5),
AppendTxt VARCHAR(191),
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
## table so far do not present the same problem as GDSpropertyattributelink
PRIMARY KEY (EANHotelID, AttributeID)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
DROP TABLE IF EXISTS gdsattributelist;
CREATE TABLE gdsattributelist
(
AttributeID INT NOT NULL,
LanguageCode VARCHAR(5),
AttributeDesc VARCHAR(255),
Type VARCHAR(15),
SubType VARCHAR(15),
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (AttributeID)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
DROP TABLE IF EXISTS gdspropertyattributelink;
CREATE TABLE gdspropertyattributelink
(
EANHotelID INT NOT NULL,
AttributeID INT NOT NULL,
LanguageCode VARCHAR(5),
AppendTxt VARCHAR(191),
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
## need all those fields to make a uniquekey
PRIMARY KEY (EANHotelID, AttributeID, AppendTxt)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
########### Image Data ####################
## there are multiple images for an hotel
## even with the same caption
## to make a unique index we need to use
## the URL instead
DROP TABLE IF EXISTS hotelimagelist;
CREATE TABLE hotelimagelist
(
EANHotelID INT NOT NULL,
Caption VARCHAR(70),
## URLs are now max 80 chars
URL VARCHAR(150) NOT NULL,
Width INT,
Height INT,
ByteSize INT,
ThumbnailURL VARCHAR(300),
DefaultImage bit,
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (URL)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE INDEX idx_hotelimagelist_eanhotelid ON hotelimagelist(EANHotelID);
########## Geography Data ###################
DROP TABLE IF EXISTS citycoordinateslist;
CREATE TABLE citycoordinateslist
(
RegionID INT NOT NULL,
RegionName VARCHAR(255),
Coordinates TEXT,
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (RegionID)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
## table to correct search term for a region
## notice there are NO spaces between words
DROP TABLE IF EXISTS aliasregionlist;
CREATE TABLE aliasregionlist
(
RegionID INT NOT NULL,
LanguageCode VARCHAR(5),
AliasString VARCHAR(255),
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
## PRIMARY KEY (RegionID, AliasString)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE INDEX idx_aliasregionid_regionid ON aliasregionlist(RegionID);
DROP TABLE IF EXISTS parentregionlist;
CREATE TABLE parentregionlist
(
RegionID INT NOT NULL,
RegionType VARCHAR(50),
RelativeSignificance VARCHAR(3),
SubClass VARCHAR(50),
RegionName VARCHAR(255),
RegionNameLong VARCHAR(510),
ParentRegionID INT,
ParentRegionType VARCHAR(50),
ParentRegionName VARCHAR(255),
ParentRegionNameLong VARCHAR(510),
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (RegionID)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
DROP TABLE IF EXISTS neighborhoodcoordinateslist;
CREATE TABLE neighborhoodcoordinateslist
(
RegionID INT NOT NULL,
RegionName VARCHAR(255),
Coordinates TEXT,
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (RegionID)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
DROP TABLE IF EXISTS regioncentercoordinateslist;
CREATE TABLE regioncentercoordinateslist
(
RegionID INT NOT NULL,
RegionName VARCHAR(255),
CenterLatitude numeric(9,6),
CenterLongitude numeric(9,6),
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (RegionID)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
DROP TABLE IF EXISTS regioneanhotelidmapping;
CREATE TABLE regioneanhotelidmapping
(
RegionID INT NOT NULL,
EANHotelID INT NOT NULL,
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (RegionID, EANHotelID)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
##
## added tables for minorRev=24+
##
DROP TABLE IF EXISTS propertylocationlist;
CREATE TABLE propertylocationlist
(
EANHotelID INT NOT NULL,
LanguageCode VARCHAR(5),
PropertyLocationDescription TEXT,
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (EANHotelID)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
DROP TABLE IF EXISTS propertyamenitieslist;
CREATE TABLE propertyamenitieslist
(
EANHotelID INT NOT NULL,
LanguageCode VARCHAR(5),
PropertyAmenitiesDescription TEXT,
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (EANHotelID)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
DROP TABLE IF EXISTS propertyroomslist;
CREATE TABLE propertyroomslist
(
EANHotelID INT NOT NULL,
LanguageCode VARCHAR(5),
PropertyRoomsDescription TEXT,
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (EANHotelID)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
DROP TABLE IF EXISTS propertybusinessamenitieslist;
CREATE TABLE propertybusinessamenitieslist
(
EANHotelID INT NOT NULL,
LanguageCode VARCHAR(5),
PropertyBusinessAmenitiesDescription TEXT,
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (EANHotelID)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
DROP TABLE IF EXISTS propertynationalratingslist;
CREATE TABLE propertynationalratingslist
(
EANHotelID INT NOT NULL,
LanguageCode VARCHAR(5),
PropertyNationalRatingsDescription TEXT,
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (EANHotelID)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
DROP TABLE IF EXISTS propertyfeeslist;
CREATE TABLE propertyfeeslist
(
EANHotelID INT NOT NULL,
LanguageCode VARCHAR(5),
PropertyFeesDescription TEXT,
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (EANHotelID)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
DROP TABLE IF EXISTS propertymandatoryfeeslist;
CREATE TABLE propertymandatoryfeeslist
(
EANHotelID INT NOT NULL,
LanguageCode VARCHAR(5),
PropertyMandatoryFeesDescription TEXT,
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (EANHotelID)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
DROP TABLE IF EXISTS propertyrenovationslist;
CREATE TABLE propertyrenovationslist
(
EANHotelID INT NOT NULL,
LanguageCode VARCHAR(5),
PropertyRenovationsDescription TEXT,
TimeStamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (EANHotelID)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;