-
Notifications
You must be signed in to change notification settings - Fork 6
/
Northwind Anchor modeling.sql
817 lines (720 loc) · 23.6 KB
/
Northwind Anchor modeling.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
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
--
-- DWH Northwind, Anchor modeling
--
DROP TABLE IF EXISTS attr_categories_name;
DROP TABLE IF EXISTS attr_categories_description;
DROP TABLE IF EXISTS attr_categories_picture;
DROP TABLE IF EXISTS attr_customer_demographics_desc;
DROP TABLE IF EXISTS attr_customers_company_name;
DROP TABLE IF EXISTS attr_customers_contact_name;
DROP TABLE IF EXISTS attr_customers_contact_title;
DROP TABLE IF EXISTS attr_customers_address;
DROP TABLE IF EXISTS attr_customers_city;
DROP TABLE IF EXISTS attr_customers_region;
DROP TABLE IF EXISTS attr_customers_postal_code;
DROP TABLE IF EXISTS attr_customers_country;
DROP TABLE IF EXISTS attr_customers_phone;
DROP TABLE IF EXISTS attr_customers_fax;
DROP TABLE IF EXISTS attr_employees_last_name;
DROP TABLE IF EXISTS attr_employees_first_name;
DROP TABLE IF EXISTS attr_employees_title;
DROP TABLE IF EXISTS attr_employees_title_of_courtesy;
DROP TABLE IF EXISTS attr_employees_birth_date;
DROP TABLE IF EXISTS attr_employees_hire_date;
DROP TABLE IF EXISTS attr_employees_address;
DROP TABLE IF EXISTS attr_employees_city;
DROP TABLE IF EXISTS attr_employees_region;
DROP TABLE IF EXISTS attr_employees_postal_code;
DROP TABLE IF EXISTS attr_employees_country;
DROP TABLE IF EXISTS attr_employees_home_phone;
DROP TABLE IF EXISTS attr_employees_extension;
DROP TABLE IF EXISTS attr_employees_photo;
DROP TABLE IF EXISTS attr_employees_notes;
DROP TABLE IF EXISTS attr_employees_photo_path;
DROP TABLE IF EXISTS attr_suppliers_company_name;
DROP TABLE IF EXISTS attr_suppliers_contact_name;
DROP TABLE IF EXISTS attr_suppliers_contact_title;
DROP TABLE IF EXISTS attr_suppliers_address;
DROP TABLE IF EXISTS attr_suppliers_city;
DROP TABLE IF EXISTS attr_suppliers_region;
DROP TABLE IF EXISTS attr_suppliers_postal_code;
DROP TABLE IF EXISTS attr_suppliers_country;
DROP TABLE IF EXISTS attr_suppliers_phone;
DROP TABLE IF EXISTS attr_suppliers_fax;
DROP TABLE IF EXISTS attr_suppliers_homepage;
DROP TABLE IF EXISTS attr_products_name;
DROP TABLE IF EXISTS attr_products_quantity_per_unit;
DROP TABLE IF EXISTS attr_products_unit_price;
DROP TABLE IF EXISTS attr_products_units_in_stock;
DROP TABLE IF EXISTS attr_products_units_on_order;
DROP TABLE IF EXISTS attr_products_reorder_level;
DROP TABLE IF EXISTS attr_products_discontinued;
DROP TABLE IF EXISTS attr_region_description;
DROP TABLE IF EXISTS attr_shippers_company_name;
DROP TABLE IF EXISTS attr_shippers_phone;
DROP TABLE IF EXISTS attr_orders_order_date;
DROP TABLE IF EXISTS attr_orders_required_date;
DROP TABLE IF EXISTS attr_orders_shipped_date;
DROP TABLE IF EXISTS attr_orders_freight;
DROP TABLE IF EXISTS attr_orders_ship_name;
DROP TABLE IF EXISTS attr_orders_ship_address;
DROP TABLE IF EXISTS attr_orders_ship_city;
DROP TABLE IF EXISTS attr_orders_ship_region;
DROP TABLE IF EXISTS attr_orders_ship_postal_code;
DROP TABLE IF EXISTS attr_orders_ship_country;
DROP TABLE IF EXISTS attr_territories;
DROP TABLE IF EXISTS attr_order_details_unit_price;
DROP TABLE IF EXISTS attr_order_details_quantity;
DROP TABLE IF EXISTS attr_order_details_discount;
DROP TABLE IF EXISTS t_categories_products;
DROP TABLE IF EXISTS t_suppliers_products;
DROP TABLE IF EXISTS t_products_order_details;
DROP TABLE IF EXISTS t_order_details_orders;
DROP TABLE IF EXISTS t_shippers_orders;
DROP TABLE IF EXISTS t_customers_orders;
DROP TABLE IF EXISTS t_customer_demographics_customers;
DROP TABLE IF EXISTS t_employees_orders;
DROP TABLE IF EXISTS t_employees_territories;
DROP TABLE IF EXISTS t_employees_employees;
DROP TABLE IF EXISTS t_territories_region;
DROP TABLE IF EXISTS a_categories;
DROP TABLE IF EXISTS a_products;
DROP TABLE IF EXISTS a_suppliers;
DROP TABLE IF EXISTS a_shippers;
DROP TABLE IF EXISTS a_orders;
DROP TABLE IF EXISTS a_customers;
DROP TABLE IF EXISTS a_customer_demographics;
DROP TABLE IF EXISTS a_employees;
DROP TABLE IF EXISTS a_territories;
DROP TABLE IF EXISTS a_region;
DROP TABLE IF EXISTS a_order_details;
--
-- Anchors
--
CREATE TABLE a_categories (
a_categories_rk bigint PRIMARY KEY,
category_id smallint,
source_system character varying(255),
processed_dttm date
);
CREATE TABLE a_products (
a_products_rk bigint PRIMARY KEY,
product_id smallint,
source_system character varying(255),
processed_dttm date
);
CREATE TABLE a_suppliers (
a_suppliers_rk bigint PRIMARY KEY,
supplier_id smallint,
source_system character varying(255),
processed_dttm date
);
CREATE TABLE a_shippers (
a_shippers_id bigint PRIMARY KEY,
shipper_id smallint,
source_system character varying(255),
processed_dttm date
);
CREATE TABLE a_orders (
a_orders_rk bigint PRIMARY KEY,
order_id smallint,
source_system character varying(255),
processed_dttm date
);
CREATE TABLE a_customers (
a_customers_rk bigint PRIMARY KEY,
customer_id smallint,
source_system character varying(255),
processed_dttm date
);
CREATE TABLE a_customer_demographics (
a_customer_demographics_rk bigint PRIMARY KEY,
customer_type_id smallint,
source_system character varying(255),
processed_dttm date
);
CREATE TABLE a_employees (
a_employees_rk bigint PRIMARY KEY,
employee_id smallint,
source_system character varying(255),
processed_dttm date
);
CREATE TABLE a_territories (
a_territories_rk bigint PRIMARY KEY,
territory_id smallint,
source_system character varying(255),
processed_dttm date
);
CREATE TABLE a_region (
a_region_rk bigint PRIMARY KEY,
region_id smallint,
source_system character varying(255),
processed_dttm date
);
CREATE TABLE a_order_details (
a_order_details_rk bigint PRIMARY KEY,
order_id smallint,
product_id smallint,
source_system character varying(255),
processed_dttm date
);
--
-- Ties
--
CREATE TABLE t_categories_products (
t_categories_products_rk bigint PRIMARY KEY,
a_categories_rk bigint,
a_products_rk bigint,
source_system character varying(255),
processed_dttm date,
FOREIGN KEY (a_categories_rk) REFERENCES a_categories,
FOREIGN KEY (a_products_rk) REFERENCES a_products
);
CREATE TABLE t_suppliers_products (
t_suppliers_products_rk bigint PRIMARY KEY,
a_suppliers_rk bigint,
a_products_rk bigint,
source_system character varying(255),
processed_dttm date,
FOREIGN KEY (a_suppliers_rk) REFERENCES a_suppliers,
FOREIGN KEY (a_products_rk) REFERENCES a_products
);
CREATE TABLE t_products_order_details (
t_products_order_details_rk bigint PRIMARY KEY,
a_products_rk bigint,
a_order_details_rk bigint,
source_system character varying(255),
processed_dttm date,
FOREIGN KEY (a_order_details_rk) REFERENCES a_order_details,
FOREIGN KEY (a_products_rk) REFERENCES a_products
);
CREATE TABLE t_order_details_orders (
t_order_details_orders_rk bigint PRIMARY KEY,
a_order_details_rk bigint,
a_orders_rk bigint,
source_system character varying(255),
processed_dttm date,
FOREIGN KEY (a_orders_rk) REFERENCES a_orders,
FOREIGN KEY (a_order_details_rk) REFERENCES a_order_details
);
CREATE TABLE t_shippers_orders (
t_shippers_orders_rk bigint PRIMARY KEY,
a_shippers_rk bigint,
a_orders_rk bigint,
source_system character varying(255),
processed_dttm date,
FOREIGN KEY (a_shippers_rk) REFERENCES a_shippers,
FOREIGN KEY (a_orders_rk) REFERENCES a_orders
);
CREATE TABLE t_customers_orders (
t_customers_orders_rk bigint PRIMARY KEY,
a_customers_rk bigint,
a_orders_rk bigint,
source_system character varying(255),
processed_dttm date,
FOREIGN KEY (a_customers_rk) REFERENCES a_customers,
FOREIGN KEY (a_orders_rk) REFERENCES a_orders
);
CREATE TABLE t_customer_demographics_customers (
t_customer_demographics_customers_rk bigint PRIMARY KEY,
a_customer_demographics_rk bigint,
a_customers_rk bigint,
source_system character varying(255),
processed_dttm date,
FOREIGN KEY (a_customer_demographics_rk) REFERENCES a_customer_demographics,
FOREIGN KEY (a_customers_rk) REFERENCES a_customers
);
CREATE TABLE t_employees_orders (
t_employees_orders_rk bigint PRIMARY KEY,
a_employees_rk bigint,
a_orders_rk bigint,
source_system character varying(255),
processed_dttm date,
FOREIGN KEY (a_employees_rk) REFERENCES a_employees,
FOREIGN KEY (a_orders_rk) REFERENCES a_orders
);
CREATE TABLE t_employees_territories (
t_employees_territories_rk bigint PRIMARY KEY,
a_employees_rk bigint,
a_territories_rk bigint,
source_system character varying(255),
processed_dttm date,
FOREIGN KEY (a_employees_rk) REFERENCES a_employees,
FOREIGN KEY (a_territories_rk) REFERENCES a_territories
);
CREATE TABLE t_employees_employees (
t_employees_employees_rk bigint PRIMARY KEY,
a_employees_rk bigint,
a_employees_rk_reports_to bigint,
source_system character varying(255),
processed_dttm date,
FOREIGN KEY (a_employees_rk) REFERENCES a_employees,
FOREIGN KEY (a_employees_rk_reports_to) REFERENCES a_employees (a_employees_rk)
);
CREATE TABLE t_territories_region (
t_territories_region_rk bigint PRIMARY KEY,
a_territories_rk bigint,
a_region_rk bigint,
source_system character varying(255),
processed_dttm date,
FOREIGN KEY (a_territories_rk) REFERENCES a_territories,
FOREIGN KEY (a_region_rk) REFERENCES a_region
);
--
-- Attributes
--
CREATE TABLE attr_categories_name (
a_categories_rk bigint,
category_name character varying(15) NOT NULL,
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_categories_rk) REFERENCES a_categories
);
CREATE TABLE attr_categories_description (
a_categories_rk bigint,
description text,
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_categories_rk) REFERENCES a_categories
);
CREATE TABLE attr_categories_picture (
a_categories_rk bigint,
picture bytea,
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_categories_rk) REFERENCES a_categories
);
CREATE TABLE attr_customer_demographics_desc (
a_customer_demographics_rk bigint,
customer_desc text,
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_customer_demographics_rk) REFERENCES a_customer_demographics
);
CREATE TABLE attr_customers_company_name (
a_customers_rk bigint,
company_name character varying(40) NOT NULL,
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_customers_rk) REFERENCES a_customers
);
CREATE TABLE attr_customers_contact_name (
a_customers_rk bigint,
contact_name character varying(30),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_customers_rk) REFERENCES a_customers
);
CREATE TABLE attr_customers_contact_title (
a_customers_rk bigint,
contact_title character varying(30),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_customers_rk) REFERENCES a_customers
);
CREATE TABLE attr_customers_address (
a_customers_rk bigint,
address character varying(60),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_customers_rk) REFERENCES a_customers
);
CREATE TABLE attr_customers_city (
a_customers_rk bigint,
city character varying(15),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_customers_rk) REFERENCES a_customers
);
CREATE TABLE attr_customers_region (
a_customers_rk bigint,
region character varying(15),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_customers_rk) REFERENCES a_customers
);
CREATE TABLE attr_customers_postal_code (
a_customers_rk bigint,
postal_code character varying(10),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_customers_rk) REFERENCES a_customers
);
CREATE TABLE attr_customers_country (
a_customers_rk bigint,
country character varying(15),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_customers_rk) REFERENCES a_customers
);
CREATE TABLE attr_customers_phone (
a_customers_rk bigint,
phone character varying(24),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_customers_rk) REFERENCES a_customers
);
CREATE TABLE attr_customers_fax (
a_customers_rk bigint,
fax character varying(24),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_customers_rk) REFERENCES a_customers
);
CREATE TABLE attr_employees_last_name (
a_employees_rk bigint,
last_name character varying(20) NOT NULL,
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_employees_rk) REFERENCES a_employees
);
CREATE TABLE attr_employees_first_name (
a_employees_rk bigint,
first_name character varying(10) NOT NULL,
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_employees_rk) REFERENCES a_employees
);
CREATE TABLE attr_employees_title (
a_employees_rk bigint,
title character varying(30),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_employees_rk) REFERENCES a_employees
);
CREATE TABLE attr_employees_title_of_courtesy (
a_employees_rk bigint,
title_of_courtesy character varying(25),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_employees_rk) REFERENCES a_employees
);
CREATE TABLE attr_employees_birth_date (
a_employees_rk bigint,
birth_date date,
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_employees_rk) REFERENCES a_employees
);
CREATE TABLE attr_employees_hire_date (
a_employees_rk bigint,
hire_date date,
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_employees_rk) REFERENCES a_employees
);
CREATE TABLE attr_employees_address (
a_employees_rk bigint,
address character varying(60),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_employees_rk) REFERENCES a_employees
);
CREATE TABLE attr_employees_city (
a_employees_rk bigint,
city character varying(15),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_employees_rk) REFERENCES a_employees
);
CREATE TABLE attr_employees_region (
a_employees_rk bigint,
region character varying(15),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_employees_rk) REFERENCES a_employees
);
CREATE TABLE attr_employees_postal_code (
a_employees_rk bigint,
postal_code character varying(10),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_employees_rk) REFERENCES a_employees
);
CREATE TABLE attr_employees_country (
a_employees_rk bigint,
country character varying(15),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_employees_rk) REFERENCES a_employees
);
CREATE TABLE attr_employees_home_phone (
a_employees_rk bigint,
home_phone character varying(24),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_employees_rk) REFERENCES a_employees
);
CREATE TABLE attr_employees_extension (
a_employees_rk bigint,
extension character varying(4),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_employees_rk) REFERENCES a_employees
);
CREATE TABLE attr_employees_photo (
a_employees_rk bigint,
photo bytea,
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_employees_rk) REFERENCES a_employees
);
CREATE TABLE attr_employees_notes (
a_employees_rk bigint,
notes text,
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_employees_rk) REFERENCES a_employees
);
CREATE TABLE attr_employees_photo_path (
a_employees_rk bigint,
photo_path character varying(255),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_employees_rk) REFERENCES a_employees
);
CREATE TABLE attr_suppliers_company_name (
a_suppliers_rk bigint,
company_name character varying(40) NOT NULL,
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_suppliers_rk) REFERENCES a_suppliers
);
CREATE TABLE attr_suppliers_contact_name (
a_suppliers_rk bigint,
contact_name character varying(30),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_suppliers_rk) REFERENCES a_suppliers
);
CREATE TABLE attr_suppliers_contact_title (
a_suppliers_rk bigint,
contact_title character varying(30),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_suppliers_rk) REFERENCES a_suppliers
);
CREATE TABLE attr_suppliers_address (
a_suppliers_rk bigint,
address character varying(60),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_suppliers_rk) REFERENCES a_suppliers
);
CREATE TABLE attr_suppliers_city (
a_suppliers_rk bigint,
city character varying(15),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_suppliers_rk) REFERENCES a_suppliers
);
CREATE TABLE attr_suppliers_region (
a_suppliers_rk bigint,
region character varying(15),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_suppliers_rk) REFERENCES a_suppliers
);
CREATE TABLE attr_suppliers_postal_code (
a_suppliers_rk bigint,
postal_code character varying(10),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_suppliers_rk) REFERENCES a_suppliers
);
CREATE TABLE attr_suppliers_country (
a_suppliers_rk bigint,
country character varying(15),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_suppliers_rk) REFERENCES a_suppliers
);
CREATE TABLE attr_suppliers_phone (
a_suppliers_rk bigint,
phone character varying(24),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_suppliers_rk) REFERENCES a_suppliers
);
CREATE TABLE attr_suppliers_fax (
a_suppliers_rk bigint,
fax character varying(24),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_suppliers_rk) REFERENCES a_suppliers
);
CREATE TABLE attr_suppliers_homepage (
a_suppliers_rk bigint,
homepage text,
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_suppliers_rk) REFERENCES a_suppliers
);
CREATE TABLE attr_products_name (
a_products_rk bigint,
product_name character varying(40) NOT NULL,
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_products_rk) REFERENCES a_products
);
CREATE TABLE attr_products_quantity_per_unit (
a_products_rk bigint,
quantity_per_unit character varying(20),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_products_rk) REFERENCES a_products
);
CREATE TABLE attr_products_unit_price (
a_products_rk bigint,
unit_price real,
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_products_rk) REFERENCES a_products
);
CREATE TABLE attr_products_units_in_stock (
a_products_rk bigint,
units_in_stock smallint,
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_products_rk) REFERENCES a_products
);
CREATE TABLE attr_products_units_on_order (
a_products_rk bigint,
units_on_order smallint,
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_products_rk) REFERENCES a_products
);
CREATE TABLE attr_products_reorder_level (
a_products_rk bigint,
reorder_level smallint,
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_products_rk) REFERENCES a_products
);
CREATE TABLE attr_products_discontinued (
a_products_rk bigint,
discontinued integer NOT NULL,
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_products_rk) REFERENCES a_products
);
CREATE TABLE attr_region_description (
a_region_rk bigint,
region_description bpchar NOT NULL,
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_region_rk) REFERENCES a_region
);
CREATE TABLE attr_shippers_company_name (
a_shippers_rk bigint,
company_name character varying(40) NOT NULL,
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_shippers_rk) REFERENCES a_shippers
);
CREATE TABLE attr_shippers_phone (
a_shippers_rk bigint,
phone character varying(24),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_shippers_rk) REFERENCES a_shippers
);
CREATE TABLE attr_orders_order_date (
a_orders_rk bigint,
order_date date,
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_orders_rk) REFERENCES a_orders
);
CREATE TABLE attr_orders_required_date (
a_orders_rk bigint,
required_date date,
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_orders_rk) REFERENCES a_orders
);
CREATE TABLE attr_orders_shipped_date (
a_orders_rk bigint,
shipped_date date,
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_orders_rk) REFERENCES a_orders
);
CREATE TABLE attr_orders_freight (
a_orders_rk bigint,
freight real,
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_orders_rk) REFERENCES a_orders
);
CREATE TABLE attr_orders_ship_name (
a_orders_rk bigint,
ship_name character varying(40),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_orders_rk) REFERENCES a_orders
);
CREATE TABLE attr_orders_ship_address (
a_orders_rk bigint,
ship_address character varying(60),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_orders_rk) REFERENCES a_orders
);
CREATE TABLE attr_orders_ship_city (
a_orders_rk bigint,
ship_city character varying(15),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_orders_rk) REFERENCES a_orders
);
CREATE TABLE attr_orders_ship_region (
a_orders_rk bigint,
ship_region character varying(15),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_orders_rk) REFERENCES a_orders
);
CREATE TABLE attr_orders_ship_postal_code (
a_orders_rk bigint,
ship_postal_code character varying(10),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_orders_rk) REFERENCES a_orders
);
CREATE TABLE attr_orders_ship_country (
a_orders_rk bigint,
ship_country character varying(15),
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_orders_rk) REFERENCES a_orders
);
CREATE TABLE attr_territories (
a_territories_rk bigint,
territory_description bpchar NOT NULL,
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_territories_rk) REFERENCES a_territories
);
CREATE TABLE attr_order_details_unit_price (
a_order_details_rk bigint,
unit_price real NOT NULL,
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_order_details_rk) REFERENCES a_order_details
);
CREATE TABLE attr_order_details_quantity (
a_order_details_rk bigint,
quantity smallint NOT NULL,
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_order_details_rk) REFERENCES a_order_details
);
CREATE TABLE attr_order_details_discount (
a_order_details_rk bigint,
discount real NOT NULL,
valid_from_dttm date,
processed_dttm date,
FOREIGN KEY (a_order_details_rk) REFERENCES a_order_details
);