-
Notifications
You must be signed in to change notification settings - Fork 3
/
tpcds_schema.sql
553 lines (528 loc) · 16.6 KB
/
tpcds_schema.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
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
CREATE TABLE dbgen_version
(
dv_version String,
dv_create_date Date,
dv_create_time String,
dv_cmdline_args String
);
CREATE TABLE customer_address
(
ca_address_sk Bigint,
ca_address_id String,
ca_street_number String,
ca_street_name String,
ca_street_type String,
ca_suite_number String,
ca_city String,
ca_county String,
ca_state String,
ca_zip String,
ca_country String,
ca_gmt_offset Double,
ca_location_type String
)
;
CREATE TABLE customer_demographics
(
cd_demo_sk Bigint,
cd_gender String,
cd_marital_status String,
cd_education_status String,
cd_purchase_estimate Bigint,
cd_credit_rating String,
cd_dep_count Bigint,
cd_dep_employed_count Bigint,
cd_dep_college_count Bigint
)
;
CREATE TABLE date_dim
(
d_date_sk Bigint,
d_date_id String,
d_date Date,
d_month_seq Bigint,
d_week_seq Bigint,
d_quarter_seq Bigint,
d_year Bigint,
d_dow Bigint,
d_moy Bigint,
d_dom Bigint,
d_qoy Bigint,
d_fy_year Bigint,
d_fy_quarter_seq Bigint,
d_fy_week_seq Bigint,
d_day_name String,
d_quarter_name String,
d_holiday String,
d_weekend String,
d_following_holiday String,
d_first_dom Bigint,
d_last_dom Bigint,
d_same_day_ly Bigint,
d_same_day_lq Bigint,
d_current_day String,
d_current_week String,
d_current_month String,
d_current_quarter String,
d_current_year String
)
;
CREATE TABLE warehouse
(
w_warehouse_sk Bigint,
w_warehouse_id String,
w_warehouse_name String,
w_warehouse_sq_ft Bigint,
w_street_number String,
w_street_name String,
w_street_type String,
w_suite_number String,
w_city String,
w_county String,
w_state String,
w_zip String,
w_country String,
w_gmt_offset Double
)
;
CREATE TABLE ship_mode
(
sm_ship_mode_sk Bigint,
sm_ship_mode_id String,
sm_type String,
sm_code String,
sm_carrier String,
sm_contract String
)
;
CREATE TABLE time_dim
(
t_time_sk Bigint,
t_time_id String,
t_time Bigint,
t_hour Bigint,
t_minute Bigint,
t_second Bigint,
t_am_pm String,
t_shift String,
t_sub_shift String,
t_meal_time String
)
;
CREATE TABLE reason
(
r_reason_sk Bigint,
r_reason_id String,
r_reason_desc String
)
;
CREATE TABLE income_band
(
ib_income_band_sk Bigint,
ib_lower_bound Bigint,
ib_upper_bound Bigint
)
;
CREATE TABLE item
(
i_item_sk Bigint,
i_item_id String,
i_rec_start_date Date,
i_rec_end_date Date,
i_item_desc String,
i_current_price Double,
i_wholesale_cost Double,
i_brand_id Bigint,
i_brand String,
i_class_id Bigint,
i_class String,
i_category_id Bigint,
i_category String,
i_manufact_id Bigint,
i_manufact String,
i_size String,
i_formulation String,
i_color String,
i_units String,
i_container String,
i_manager_id Bigint,
i_product_name String
)
;
CREATE TABLE store
(
s_store_sk Bigint,
s_store_id String,
s_rec_start_date Date,
s_rec_end_date Date,
s_closed_date_sk Bigint,
s_store_name String,
s_number_employees Bigint,
s_floor_space Bigint,
s_hours String,
s_manager String,
s_market_id Bigint,
s_geography_class String,
s_market_desc String,
s_market_manager String,
s_division_id Bigint,
s_division_name String,
s_company_id Bigint,
s_company_name String,
s_street_number String,
s_street_name String,
s_street_type String,
s_suite_number String,
s_city String,
s_county String,
s_state String,
s_zip String,
s_country String,
s_gmt_offset Double,
s_tax_precentage Double
)
;
CREATE TABLE call_center
(
cc_call_center_sk Bigint,
cc_call_center_id String,
cc_rec_start_date Date,
cc_rec_end_date Date,
cc_closed_date_sk Bigint,
cc_open_date_sk Bigint,
cc_name String,
cc_class String,
cc_employees Bigint,
cc_sq_ft Bigint,
cc_hours String,
cc_manager String,
cc_mkt_id Bigint,
cc_mkt_class String,
cc_mkt_desc String,
cc_market_manager String,
cc_division Bigint,
cc_division_name String,
cc_company Bigint,
cc_company_name String,
cc_street_number String,
cc_street_name String,
cc_street_type String,
cc_suite_number String,
cc_city String,
cc_county String,
cc_state String,
cc_zip String,
cc_country String,
cc_gmt_offset Double,
cc_tax_percentage Double
)
;
CREATE TABLE customer
(
c_customer_sk Bigint,
c_customer_id String,
c_current_cdemo_sk Bigint,
c_current_hdemo_sk Bigint,
c_current_addr_sk Bigint,
c_first_shipto_date_sk Bigint,
c_first_sales_date_sk Bigint,
c_salutation String,
c_first_name String,
c_last_name String,
c_preferred_cust_flag String,
c_birth_day Bigint,
c_birth_month Bigint,
c_birth_year Bigint,
c_birth_country String,
c_login String,
c_email_address String,
c_last_review_date String
)
;
CREATE TABLE web_site
(
web_site_sk Bigint,
web_site_id String,
web_rec_start_date Date,
web_rec_end_date Date,
web_name String,
web_open_date_sk Bigint,
web_close_date_sk Bigint,
web_class String,
web_manager String,
web_mkt_id Bigint,
web_mkt_class String,
web_mkt_desc String,
web_market_manager String,
web_company_id Bigint,
web_company_name String,
web_street_number String,
web_street_name String,
web_street_type String,
web_suite_number String,
web_city String,
web_county String,
web_state String,
web_zip String,
web_country String,
web_gmt_offset Double,
web_tax_percentage Double
)
;
CREATE TABLE store_returns
(
sr_returned_date_sk Bigint,
sr_return_time_sk Bigint,
sr_item_sk Bigint,
sr_customer_sk Bigint,
sr_cdemo_sk Bigint,
sr_hdemo_sk Bigint,
sr_addr_sk Bigint,
sr_store_sk Bigint,
sr_reason_sk Bigint,
sr_ticket_number Bigint,
sr_return_quantity Bigint,
sr_return_amt Double,
sr_return_tax Double,
sr_return_amt_inc_tax Double,
sr_fee Double,
sr_return_ship_cost Double,
sr_refunded_cash Double,
sr_reversed_charge Double,
sr_store_credit Double,
sr_net_loss Double
)
;
CREATE TABLE household_demographics
(
hd_demo_sk Bigint,
hd_income_band_sk Bigint,
hd_buy_potential String,
hd_dep_count Bigint,
hd_vehicle_count Bigint
)
;
CREATE TABLE web_page
(
wp_web_page_sk Bigint,
wp_web_page_id String,
wp_rec_start_date Date,
wp_rec_end_date Date,
wp_creation_date_sk Bigint,
wp_access_date_sk Bigint,
wp_autogen_flag String,
wp_customer_sk Bigint,
wp_url String,
wp_type String,
wp_char_count Bigint,
wp_link_count Bigint,
wp_image_count Bigint,
wp_max_ad_count Bigint
)
;
CREATE TABLE promotion
(
p_promo_sk Bigint,
p_promo_id String,
p_start_date_sk Bigint,
p_end_date_sk Bigint,
p_item_sk Bigint,
p_cost Double,
p_response_target Bigint,
p_promo_name String,
p_channel_dmail String,
p_channel_email String,
p_channel_catalog String,
p_channel_tv String,
p_channel_radio String,
p_channel_press String,
p_channel_event String,
p_channel_demo String,
p_channel_details String,
p_purpose String,
p_discount_active String
)
;
CREATE TABLE catalog_page
(
cp_catalog_page_sk Bigint,
cp_catalog_page_id String,
cp_start_date_sk Bigint,
cp_end_date_sk Bigint,
cp_department String,
cp_catalog_number Bigint,
cp_catalog_page_number Bigint,
cp_description String,
cp_type String
)
;
CREATE TABLE inventory
(
inv_date_sk Bigint,
inv_item_sk Bigint,
inv_warehouse_sk Bigint,
inv_quantity_on_hand Bigint
)
;
CREATE TABLE catalog_returns
(
cr_returned_date_sk Bigint,
cr_returned_time_sk Bigint,
cr_item_sk Bigint,
cr_refunded_customer_sk Bigint,
cr_refunded_cdemo_sk Bigint,
cr_refunded_hdemo_sk Bigint,
cr_refunded_addr_sk Bigint,
cr_returning_customer_sk Bigint,
cr_returning_cdemo_sk Bigint,
cr_returning_hdemo_sk Bigint,
cr_returning_addr_sk Bigint,
cr_call_center_sk Bigint,
cr_catalog_page_sk Bigint,
cr_ship_mode_sk Bigint,
cr_warehouse_sk Bigint,
cr_reason_sk Bigint,
cr_order_number Bigint,
cr_return_quantity Bigint,
cr_return_amount Double,
cr_return_tax Double,
cr_return_amt_inc_tax Double,
cr_fee Double,
cr_return_ship_cost Double,
cr_refunded_cash Double,
cr_reversed_charge Double,
cr_store_credit Double,
cr_net_loss Double
)
;
CREATE TABLE web_returns
(
wr_returned_date_sk Bigint,
wr_returned_time_sk Bigint,
wr_item_sk Bigint,
wr_refunded_customer_sk Bigint,
wr_refunded_cdemo_sk Bigint,
wr_refunded_hdemo_sk Bigint,
wr_refunded_addr_sk Bigint,
wr_returning_customer_sk Bigint,
wr_returning_cdemo_sk Bigint,
wr_returning_hdemo_sk Bigint,
wr_returning_addr_sk Bigint,
wr_web_page_sk Bigint,
wr_reason_sk Bigint,
wr_order_number Bigint,
wr_return_quantity Bigint,
wr_return_amt Double,
wr_return_tax Double,
wr_return_amt_inc_tax Double,
wr_fee Double,
wr_return_ship_cost Double,
wr_refunded_cash Double,
wr_reversed_charge Double,
wr_account_credit Double,
wr_net_loss Double
)
;
CREATE TABLE web_sales
(
ws_sold_date_sk Bigint,
ws_sold_time_sk Bigint,
ws_ship_date_sk Bigint,
ws_item_sk Bigint,
ws_bill_customer_sk Bigint,
ws_bill_cdemo_sk Bigint,
ws_bill_hdemo_sk Bigint,
ws_bill_addr_sk Bigint,
ws_ship_customer_sk Bigint,
ws_ship_cdemo_sk Bigint,
ws_ship_hdemo_sk Bigint,
ws_ship_addr_sk Bigint,
ws_web_page_sk Bigint,
ws_web_site_sk Bigint,
ws_ship_mode_sk Bigint,
ws_warehouse_sk Bigint,
ws_promo_sk Bigint,
ws_order_number Bigint,
ws_quantity Bigint,
ws_wholesale_cost Double,
ws_list_price Double,
ws_sales_price Double,
ws_ext_discount_amt Double,
ws_ext_sales_price Double,
ws_ext_wholesale_cost Double,
ws_ext_list_price Double,
ws_ext_tax Double,
ws_coupon_amt Double,
ws_ext_ship_cost Double,
ws_net_paid Double,
ws_net_paid_inc_tax Double,
ws_net_paid_inc_ship Double,
ws_net_paid_inc_ship_tax Double,
ws_net_profit Double
)
;
CREATE TABLE catalog_sales
(
cs_sold_date_sk Bigint,
cs_sold_time_sk Bigint,
cs_ship_date_sk Bigint,
cs_bill_customer_sk Bigint,
cs_bill_cdemo_sk Bigint,
cs_bill_hdemo_sk Bigint,
cs_bill_addr_sk Bigint,
cs_ship_customer_sk Bigint,
cs_ship_cdemo_sk Bigint,
cs_ship_hdemo_sk Bigint,
cs_ship_addr_sk Bigint,
cs_call_center_sk Bigint,
cs_catalog_page_sk Bigint,
cs_ship_mode_sk Bigint,
cs_warehouse_sk Bigint,
cs_item_sk Bigint,
cs_promo_sk Bigint,
cs_order_number Bigint,
cs_quantity Bigint,
cs_wholesale_cost Double,
cs_list_price Double,
cs_sales_price Double,
cs_ext_discount_amt Double,
cs_ext_sales_price Double,
cs_ext_wholesale_cost Double,
cs_ext_list_price Double,
cs_ext_tax Double,
cs_coupon_amt Double,
cs_ext_ship_cost Double,
cs_net_paid Double,
cs_net_paid_inc_tax Double,
cs_net_paid_inc_ship Double,
cs_net_paid_inc_ship_tax Double,
cs_net_profit Double
)
;
CREATE TABLE store_sales
(
ss_sold_date_sk Bigint,
ss_sold_time_sk Bigint,
ss_item_sk Bigint,
ss_customer_sk Bigint,
ss_cdemo_sk Bigint,
ss_hdemo_sk Bigint,
ss_addr_sk Bigint,
ss_store_sk Bigint,
ss_promo_sk Bigint,
ss_ticket_number Bigint,
ss_quantity Bigint,
ss_wholesale_cost Double,
ss_list_price Double,
ss_sales_price Double,
ss_ext_discount_amt Double,
ss_ext_sales_price Double,
ss_ext_wholesale_cost Double,
ss_ext_list_price Double,
ss_ext_tax Double,
ss_coupon_amt Double,
ss_net_paid Double,
ss_net_paid_inc_tax Double,
ss_net_profit Double
)
;