You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

208 lines
3.6 KiB

# DB DS53
## AGG_YR_QT_RN_ST_LN_CA_SR
```sql
ID INT
YEAR INT
QUARTER VARCHAR(2)
STATE VARCHAR(20)
LINE VARCHAR(20)
CATEGORY VARCHAR(25)
SALES_REVENUE INT
```
## AGG_YR_THRU_SN_SR_QT_MA
```sql
ID INT
YEAR INT
QUARTER VARCHAR(2)
MONTH INT
MONTH_NAME VARCHAR(10)
WEEK INT
CITY VARCHAR(20)
STORE_NAME VARCHAR(30)
SALES_REVENUE INT
QUANTITY_SOLD INT
MARGIN INT
```
## ARTICLE_COLOR_LOOKUP
```sql
article_code INT NOT NULL,
color_code INT NOT NULL,
article_label VARCHAR(45),
color_label VARCHAR(30),
category VARCHAR(25),
sale_price DECIMAL(8,2),
family_name VARCHAR(20),
family_code VARCHAR(3),
PRIMARY KEY (article_code, color_code)
```
```
LOAD DATA LOCAL INFILE './emode/article_color_lookup.csv' INTO TABLE article_color_lookup FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n'
(
article_code,
color_code,
article_label,
color_label,
category,
sale_price,
family_name,
family_code
);
```
## ARTICLE_LOOKUP
```sql
article_code INT NOT NULL,
article_label VARCHAR(45),
category VARCHAR(25),
sale_price DECIMAL(8,2),
family_name VARCHAR(20),
family_code VARCHAR(3),
PRIMARY KEY (article_code)
```
```
LOAD DATA LOCAL INFILE './emode/article_lookup.csv' INTO TABLE article_lookup FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' (
article_code,
article_label,
category,
sale_price,
family_name,
family_code
);
```
## ARTICLE_LOOKUP_CRITERIA
```sql
ID INT
ARTICLE_CODE INT
CRITERIA_TYPE VARCHAR(2)
CRITERIA VARCHAR(2)
CRITERIA_TYPE_LABEL VARCHAR(20)
CRITERIA_LABEL VARCHAR(40)
```
## CALENDAR_YEAR_LOOKUP
```sql
week_key INT NOT NULL,
week_in_year INT NOT NULL,
year INT NOT NULL,
fiscal_period VARCHAR(4),
year_week VARCHAR(7) NOT NULL,
quarter INT NOT NULL,
month_name VARCHAR(10) NOT NULL,
month INT NOT NULL,
holiday_flag VARCHAR(1),
PRIMARY KEY (week_key)
```
```
LOAD DATA LOCAL INFILE './emode/calendar_year_lookup.csv' INTO TABLE calendar_year_lookup FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n'
(
week_key,
week_in_year,
year,
fiscal_period,
year_week,
quarter,
month_name,
month,
holiday_flag
);
```
## OUTLET_LOOKUP
```sql
shop_name VARCHAR(30),
address_1 VARCHAR(20),
manager VARCHAR(10),
date_open DATE NOT NULL,
open VARCHAR(1),
owned_outright VARCHAR(1),
floor_space INT,
zip_code VARCHAR(6),
city VARCHAR(20),
state VARCHAR(20),
shop_code INT NOT NULL,
PRIMARY KEY (shop_code)
```
Warning: addresses contain commas, which the dump did not escape
```
LOAD DATA LOCAL INFILE './emode/outlet_lookup.csv' INTO TABLE outlet_lookup FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n'
(
shop_name,
address_1,
manager,
@date_open,
open,
owned_outright,
floor_space,
zip_code,
city,
state,
shop_code
)
SET date_open = STR_TO_DATE(@date_open, "%d-%b-%y");
```
## PRODUCT_PROMOTION_FACTS
```sql
id INT
article_code INT
week_key INT
duration INT
promotion_key INT
promotion_cost INT
```
## PROMOTION_LOOKUP
```sql
promotion_key INT
promotion VARCHAR(1)
print_flag VARCHAR(1)
radio_flag VARCHAR(1)
television_flag VARCHAR(1)
direct_mail_flag VARCHAR(1)
```
## SHOP_FACTS
```sql
id INT NOT NULL AUTO_INCREMENT,
article_code INT NOT NULL,
color_code INT NOT NULL,
week_key INT NOT NULL,
shop_code INT NOT NULL,
margin DECIMAL(13,2) NOT NULL,
amount_sold DECIMAL(13,2) NOT NULL,
quantity_sold DECIMAL(13,2) NOT NULL,
PRIMARY KEY (id)
```
```
LOAD DATA LOCAL INFILE './emode/shop_facts.csv' INTO TABLE shop_facts FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' (
id,
article_code,
color_code,
week_key,
shop_code,
margin,
amount_sold,
quantity_sold
);
```