1
0
forked from s26450/hurtownia

create sql

This commit is contained in:
Mariusz Sielski 2018-11-20 19:11:02 +01:00 committed by Mariusz Sielski
parent ad516c825f
commit 9c407f4e56
2 changed files with 314 additions and 0 deletions

View File

@ -0,0 +1,250 @@
English short name Alpha-2 code Alpha-3 code Numeric
Afghanistan AF AFG 004
Åland Islands AX ALA 248
Albania AL ALB 008
Algeria DZ DZA 012
American Samoa AS ASM 016
Andorra AD AND 020
Angola AO AGO 024
Anguilla AI AIA 660
Antarctica AQ ATA 010
Antigua and Barbuda AG ATG 028
Argentina AR ARG 032
Armenia AM ARM 051
Aruba AW ABW 533
Australia AU AUS 036
Austria AT AUT 040
Azerbaijan AZ AZE 031
Bahamas BS BHS 044
Bahrain BH BHR 048
Bangladesh BD BGD 050
Barbados BB BRB 052
Belarus BY BLR 112
Belgium BE BEL 056
Belize BZ BLZ 084
Benin BJ BEN 204
Bermuda BM BMU 060
Bhutan BT BTN 064
Bolivia BO BOL 068
Bonaire BQ BES 535
Bosnia and Herzegovina BA BIH 070
Botswana BW BWA 072
Bouvet Island BV BVT 074
Brazil BR BRA 076
British Indian Ocean Territory IO IOT 086
Brunei Darussalam BN BRN 096
Bulgaria BG BGR 100
Burkina Faso BF BFA 854
Burundi BI BDI 108
Cabo Verde CV CPV 132
Cambodia KH KHM 116
Cameroon CM CMR 120
Canada CA CAN 124
Cayman Islands KY CYM 136
Central African Republic CF CAF 140
Chad TD TCD 148
Chile CL CHL 152
China CN CHN 156
Christmas Island CX CXR 162
Cocos Islands CC CCK 166
Colombia CO COL 170
Comoros KM COM 174
Congo CG COG 178
Democratic Republic of the Congo CD COD 180
Cook Islands CK COK 184
Costa Rica CR CRI 188
Côte d'Ivoire CI CIV 384
Croatia HR HRV 191
Cuba CU CUB 192
Curaçao CW CUW 531
Cyprus CY CYP 196
Czech Republic CZ CZE 203
Denmark DK DNK 208
Djibouti DJ DJI 262
Dominica DM DMA 212
Dominican Republic DO DOM 214
Ecuador EC ECU 218
Egypt EG EGY 818
El Salvador SV SLV 222
Equatorial Guinea GQ GNQ 226
Eritrea ER ERI 232
Estonia EE EST 233
Ethiopia ET ETH 231
Falkland Islands [Malvinas] FK FLK 238
Faroe Islands FO FRO 234
Fiji FJ FJI 242
Finland FI FIN 246
France FR FRA 250
French Guiana GF GUF 254
French Polynesia PF PYF 258
French Southern Territories TF ATF 260
Gabon GA GAB 266
Gambia GM GMB 270
Georgia GE GEO 268
Germany DE DEU 276
Ghana GH GHA 288
Gibraltar GI GIB 292
Greece GR GRC 300
Greenland GL GRL 304
Grenada GD GRD 308
Guadeloupe GP GLP 312
Guam GU GUM 316
Guatemala GT GTM 320
Guernsey GG GGY 831
Guinea GN GIN 324
Guinea-Bissau GW GNB 624
Guyana GY GUY 328
Haiti HT HTI 332
Heard Island and McDonald Islands HM HMD 334
Vatican City State VA VAT 336
Honduras HN HND 340
Hong Kong HK HKG 344
Hungary HU HUN 348
Iceland IS ISL 352
India IN IND 356
Indonesia ID IDN 360
Iran IR IRN 364
Iraq IQ IRQ 368
Ireland IE IRL 372
Isle of Man IM IMN 833
Israel IL ISR 376
Italy IT ITA 380
Jamaica JM JAM 388
Japan JP JPN 392
Jersey JE JEY 832
Jordan JO JOR 400
Kazakhstan KZ KAZ 398
Kenya KE KEN 404
Kiribati KI KIR 296
Democratic People's Republic of Korea KP PRK 408
Republic of Korea KR KOR 410
Kuwait KW KWT 414
Kyrgyzstan KG KGZ 417
Lao People's Democratic Republic LA LAO 418
Latvia LV LVA 428
Lebanon LB LBN 422
Lesotho LS LSO 426
Liberia LR LBR 430
Libya LY LBY 434
Liechtenstein LI LIE 438
Lithuania LT LTU 440
Luxembourg LU LUX 442
Macao MO MAC 446
Macedonia MK MKD 807
Madagascar MG MDG 450
Malawi MW MWI 454
Malaysia MY MYS 458
Maldives MV MDV 462
Mali ML MLI 466
Malta MT MLT 470
Marshall Islands MH MHL 584
Martinique MQ MTQ 474
Mauritania MR MRT 478
Mauritius MU MUS 480
Mayotte YT MYT 175
Mexico MX MEX 484
Federated States of Micronesia FM FSM 583
Moldova MD MDA 498
Monaco MC MCO 492
Mongolia MN MNG 496
Montenegro ME MNE 499
Montserrat MS MSR 500
Morocco MA MAR 504
Mozambique MZ MOZ 508
Myanmar MM MMR 104
Namibia NA NAM 516
Nauru NR NRU 520
Nepal NP NPL 524
Netherlands NL NLD 528
New Caledonia NC NCL 540
New Zealand NZ NZL 554
Nicaragua NI NIC 558
Niger NE NER 562
Nigeria NG NGA 566
Niue NU NIU 570
Norfolk Island NF NFK 574
Northern Mariana Islands MP MNP 580
Norway NO NOR 578
Oman OM OMN 512
Pakistan PK PAK 586
Palau PW PLW 585
Palestine PS PSE 275
Panama PA PAN 591
Papua New Guinea PG PNG 598
Paraguay PY PRY 600
Peru PE PER 604
Philippines PH PHL 608
Pitcairn PN PCN 612
Poland PL POL 616
Portugal PT PRT 620
Puerto Rico PR PRI 630
Qatar QA QAT 634
Réunion RE REU 638
Romania RO ROU 642
Russian Federation RU RUS 643
Rwanda RW RWA 646
Saint Barthélemy BL BLM 652
Saint Helena, Ascension and Tristan da Cunha SH SHN 654
Saint Kitts and Nevis KN KNA 659
Saint Lucia LC LCA 662
Saint Martin (French part) MF MAF 663
Saint Pierre and Miquelon PM SPM 666
Saint Vincent and the Grenadines VC VCT 670
Samoa WS WSM 882
San Marino SM SMR 674
Sao Tome and Principe ST STP 678
Saudi Arabia SA SAU 682
Senegal SN SEN 686
Serbia RS SRB 688
Seychelles SC SYC 690
Sierra Leone SL SLE 694
Singapore SG SGP 702
Sint Maarten (Dutch part) SX SXM 534
Slovakia SK SVK 703
Slovenia SI SVN 705
Solomon Islands SB SLB 090
Somalia SO SOM 706
South Africa ZA ZAF 710
South Georgia and the South Sandwich Islands GS SGS 239
South Sudan SS SSD 728
Spain ES ESP 724
Sri Lanka LK LKA 144
Sudan SD SDN 729
Suriname SR SUR 740
Svalbard and Jan Mayen SJ SJM 744
Swaziland SZ SWZ 748
Sweden SE SWE 752
Switzerland CH CHE 756
Syrian Arab Republic SY SYR 760
Taiwan TW TWN 158
Tajikistan TJ TJK 762
Tanzania, United Republic of TZ TZA 834
Thailand TH THA 764
Timor-Leste TL TLS 626
Togo TG TGO 768
Tokelau TK TKL 772
Tonga TO TON 776
Trinidad and Tobago TT TTO 780
Tunisia TN TUN 788
Turkey TR TUR 792
Turkmenistan TM TKM 795
Turks and Caicos Islands TC TCA 796
Tuvalu TV TUV 798
Uganda UG UGA 800
Ukraine UA UKR 804
United Arab Emirates AE ARE 784
United Kingdom GB GBR 826
United States US USA 840
United States Minor Outlying Islands UM UMI 581
Uruguay UY URY 858
Uzbekistan UZ UZB 860
Vanuatu VU VUT 548
Venezuela, Bolivarian Republic of VE VEN 862
Viet Nam VN VNM 704
Virgin Islands (British) VG VGB 092
Virgin Islands (U.S.) VI VIR 850
Wallis and Futuna WF WLF 876
Western Sahara EH ESH 732
Yemen YE YEM 887
Zambia ZM ZMB 894
Zimbabwe ZW ZWE 716
1 English short name Alpha-2 code Alpha-3 code Numeric
2 Afghanistan AF AFG 004
3 Åland Islands AX ALA 248
4 Albania AL ALB 008
5 Algeria DZ DZA 012
6 American Samoa AS ASM 016
7 Andorra AD AND 020
8 Angola AO AGO 024
9 Anguilla AI AIA 660
10 Antarctica AQ ATA 010
11 Antigua and Barbuda AG ATG 028
12 Argentina AR ARG 032
13 Armenia AM ARM 051
14 Aruba AW ABW 533
15 Australia AU AUS 036
16 Austria AT AUT 040
17 Azerbaijan AZ AZE 031
18 Bahamas BS BHS 044
19 Bahrain BH BHR 048
20 Bangladesh BD BGD 050
21 Barbados BB BRB 052
22 Belarus BY BLR 112
23 Belgium BE BEL 056
24 Belize BZ BLZ 084
25 Benin BJ BEN 204
26 Bermuda BM BMU 060
27 Bhutan BT BTN 064
28 Bolivia BO BOL 068
29 Bonaire BQ BES 535
30 Bosnia and Herzegovina BA BIH 070
31 Botswana BW BWA 072
32 Bouvet Island BV BVT 074
33 Brazil BR BRA 076
34 British Indian Ocean Territory IO IOT 086
35 Brunei Darussalam BN BRN 096
36 Bulgaria BG BGR 100
37 Burkina Faso BF BFA 854
38 Burundi BI BDI 108
39 Cabo Verde CV CPV 132
40 Cambodia KH KHM 116
41 Cameroon CM CMR 120
42 Canada CA CAN 124
43 Cayman Islands KY CYM 136
44 Central African Republic CF CAF 140
45 Chad TD TCD 148
46 Chile CL CHL 152
47 China CN CHN 156
48 Christmas Island CX CXR 162
49 Cocos Islands CC CCK 166
50 Colombia CO COL 170
51 Comoros KM COM 174
52 Congo CG COG 178
53 Democratic Republic of the Congo CD COD 180
54 Cook Islands CK COK 184
55 Costa Rica CR CRI 188
56 Côte d'Ivoire CI CIV 384
57 Croatia HR HRV 191
58 Cuba CU CUB 192
59 Curaçao CW CUW 531
60 Cyprus CY CYP 196
61 Czech Republic CZ CZE 203
62 Denmark DK DNK 208
63 Djibouti DJ DJI 262
64 Dominica DM DMA 212
65 Dominican Republic DO DOM 214
66 Ecuador EC ECU 218
67 Egypt EG EGY 818
68 El Salvador SV SLV 222
69 Equatorial Guinea GQ GNQ 226
70 Eritrea ER ERI 232
71 Estonia EE EST 233
72 Ethiopia ET ETH 231
73 Falkland Islands [Malvinas] FK FLK 238
74 Faroe Islands FO FRO 234
75 Fiji FJ FJI 242
76 Finland FI FIN 246
77 France FR FRA 250
78 French Guiana GF GUF 254
79 French Polynesia PF PYF 258
80 French Southern Territories TF ATF 260
81 Gabon GA GAB 266
82 Gambia GM GMB 270
83 Georgia GE GEO 268
84 Germany DE DEU 276
85 Ghana GH GHA 288
86 Gibraltar GI GIB 292
87 Greece GR GRC 300
88 Greenland GL GRL 304
89 Grenada GD GRD 308
90 Guadeloupe GP GLP 312
91 Guam GU GUM 316
92 Guatemala GT GTM 320
93 Guernsey GG GGY 831
94 Guinea GN GIN 324
95 Guinea-Bissau GW GNB 624
96 Guyana GY GUY 328
97 Haiti HT HTI 332
98 Heard Island and McDonald Islands HM HMD 334
99 Vatican City State VA VAT 336
100 Honduras HN HND 340
101 Hong Kong HK HKG 344
102 Hungary HU HUN 348
103 Iceland IS ISL 352
104 India IN IND 356
105 Indonesia ID IDN 360
106 Iran IR IRN 364
107 Iraq IQ IRQ 368
108 Ireland IE IRL 372
109 Isle of Man IM IMN 833
110 Israel IL ISR 376
111 Italy IT ITA 380
112 Jamaica JM JAM 388
113 Japan JP JPN 392
114 Jersey JE JEY 832
115 Jordan JO JOR 400
116 Kazakhstan KZ KAZ 398
117 Kenya KE KEN 404
118 Kiribati KI KIR 296
119 Democratic People's Republic of Korea KP PRK 408
120 Republic of Korea KR KOR 410
121 Kuwait KW KWT 414
122 Kyrgyzstan KG KGZ 417
123 Lao People's Democratic Republic LA LAO 418
124 Latvia LV LVA 428
125 Lebanon LB LBN 422
126 Lesotho LS LSO 426
127 Liberia LR LBR 430
128 Libya LY LBY 434
129 Liechtenstein LI LIE 438
130 Lithuania LT LTU 440
131 Luxembourg LU LUX 442
132 Macao MO MAC 446
133 Macedonia MK MKD 807
134 Madagascar MG MDG 450
135 Malawi MW MWI 454
136 Malaysia MY MYS 458
137 Maldives MV MDV 462
138 Mali ML MLI 466
139 Malta MT MLT 470
140 Marshall Islands MH MHL 584
141 Martinique MQ MTQ 474
142 Mauritania MR MRT 478
143 Mauritius MU MUS 480
144 Mayotte YT MYT 175
145 Mexico MX MEX 484
146 Federated States of Micronesia FM FSM 583
147 Moldova MD MDA 498
148 Monaco MC MCO 492
149 Mongolia MN MNG 496
150 Montenegro ME MNE 499
151 Montserrat MS MSR 500
152 Morocco MA MAR 504
153 Mozambique MZ MOZ 508
154 Myanmar MM MMR 104
155 Namibia NA NAM 516
156 Nauru NR NRU 520
157 Nepal NP NPL 524
158 Netherlands NL NLD 528
159 New Caledonia NC NCL 540
160 New Zealand NZ NZL 554
161 Nicaragua NI NIC 558
162 Niger NE NER 562
163 Nigeria NG NGA 566
164 Niue NU NIU 570
165 Norfolk Island NF NFK 574
166 Northern Mariana Islands MP MNP 580
167 Norway NO NOR 578
168 Oman OM OMN 512
169 Pakistan PK PAK 586
170 Palau PW PLW 585
171 Palestine PS PSE 275
172 Panama PA PAN 591
173 Papua New Guinea PG PNG 598
174 Paraguay PY PRY 600
175 Peru PE PER 604
176 Philippines PH PHL 608
177 Pitcairn PN PCN 612
178 Poland PL POL 616
179 Portugal PT PRT 620
180 Puerto Rico PR PRI 630
181 Qatar QA QAT 634
182 Réunion RE REU 638
183 Romania RO ROU 642
184 Russian Federation RU RUS 643
185 Rwanda RW RWA 646
186 Saint Barthélemy BL BLM 652
187 Saint Helena, Ascension and Tristan da Cunha SH SHN 654
188 Saint Kitts and Nevis KN KNA 659
189 Saint Lucia LC LCA 662
190 Saint Martin (French part) MF MAF 663
191 Saint Pierre and Miquelon PM SPM 666
192 Saint Vincent and the Grenadines VC VCT 670
193 Samoa WS WSM 882
194 San Marino SM SMR 674
195 Sao Tome and Principe ST STP 678
196 Saudi Arabia SA SAU 682
197 Senegal SN SEN 686
198 Serbia RS SRB 688
199 Seychelles SC SYC 690
200 Sierra Leone SL SLE 694
201 Singapore SG SGP 702
202 Sint Maarten (Dutch part) SX SXM 534
203 Slovakia SK SVK 703
204 Slovenia SI SVN 705
205 Solomon Islands SB SLB 090
206 Somalia SO SOM 706
207 South Africa ZA ZAF 710
208 South Georgia and the South Sandwich Islands GS SGS 239
209 South Sudan SS SSD 728
210 Spain ES ESP 724
211 Sri Lanka LK LKA 144
212 Sudan SD SDN 729
213 Suriname SR SUR 740
214 Svalbard and Jan Mayen SJ SJM 744
215 Swaziland SZ SWZ 748
216 Sweden SE SWE 752
217 Switzerland CH CHE 756
218 Syrian Arab Republic SY SYR 760
219 Taiwan TW TWN 158
220 Tajikistan TJ TJK 762
221 Tanzania, United Republic of TZ TZA 834
222 Thailand TH THA 764
223 Timor-Leste TL TLS 626
224 Togo TG TGO 768
225 Tokelau TK TKL 772
226 Tonga TO TON 776
227 Trinidad and Tobago TT TTO 780
228 Tunisia TN TUN 788
229 Turkey TR TUR 792
230 Turkmenistan TM TKM 795
231 Turks and Caicos Islands TC TCA 796
232 Tuvalu TV TUV 798
233 Uganda UG UGA 800
234 Ukraine UA UKR 804
235 United Arab Emirates AE ARE 784
236 United Kingdom GB GBR 826
237 United States US USA 840
238 United States Minor Outlying Islands UM UMI 581
239 Uruguay UY URY 858
240 Uzbekistan UZ UZB 860
241 Vanuatu VU VUT 548
242 Venezuela, Bolivarian Republic of VE VEN 862
243 Viet Nam VN VNM 704
244 Virgin Islands (British) VG VGB 092
245 Virgin Islands (U.S.) VI VIR 850
246 Wallis and Futuna WF WLF 876
247 Western Sahara EH ESH 732
248 Yemen YE YEM 887
249 Zambia ZM ZMB 894
250 Zimbabwe ZW ZWE 716

64
sql/create.sql Normal file
View File

@ -0,0 +1,64 @@
DROP TABLE IF EXISTS dim_factories;
CREATE TABLE dim_factories (
factory_sk INTEGER identity(1,1) PRIMARY KEY,
factory_bk NVARCHAR(100) NOT NULL,
factory_name NVARCHAR(250),
factory_country NVARCHAR(250)
);
GO
DROP TABLE IF EXISTS dim_time;
CREATE TABLE dim_time (
time_sk INTEGER identity(1,1) PRIMARY KEY,
time_bk DATE NOT NULL,
time_string NCHAR(10) NOT NULL,
year INTEGER,
month INTEGER,
day INTEGER,
quarter INTEGER
);
GO
DROP TABLE IF EXISTS dim_drugs;
CREATE TABLE dim_drugs (
drug_sk INTEGER identity(1, 1) PRIMARY KEY,
DrugProductId INTEGER NOT NULL, -- business key
RecordStatus CHAR(1), -- A for active, D for deactivated
DrugProductName NVARCHAR(250),
RONumber NVARCHAR(20),
DrugProductFamilyId INTEGER,
DrugProductFamilyName NVARCHAR(250)
);
GO
DROP TABLE IF EXISTS dim_countries;
CREATE TABLE dim_countries (
country_sk INTEGER identity(1, 1) PRIMARY KEY,
country_code NVARCHAR(2), -- business key
country_name NVARCHAR(250)
);
DROP TABLE IF EXISTS dim_claim_statuses;
CREATE TABLE dim_claim_statuses (
status_sk INTEGER identity(1, 1) PRIMARY KEY,
status_code VARCHAR(1) NOT NULL, -- A for Accepted, D for Declined, W for Waiting
status_description NVARCHAR(50)
);
GO
-- insert statuses
INSERT INTO dim_claim_statuses(status_code, status_description)
VALUES
('A', 'Accepted'),
('D', 'Declined'),
('W', 'Waiting');
GO
DROP TABLE IF EXISTS dim_indications;
CREATE TABLE dim_indications (
indication_sk INTEGER identity(1, 1) PRIMARY KEY,
IndicationId INTEGER NOT NULL,
RecordStatus CHAR(1),
IndicationDescription NVARCHAR(500)
);
GO