CREATE TABLE account (account_id INTEGER NOT NULL,account_parent INTEGER,account_description VARCHAR(30),account_type VARCHAR(30) NOT NULL,account_rollup VARCHAR(30) NOT NULL,Custom_Members VARCHAR(255));
CREATE UNIQUE INDEX i_account_id ON account(account_id);
CREATE INDEX i_account_parent ON account(account_parent);
CREATE TABLE agg_c_10_sales_fact_1997 (month_of_year SMALLINT NOT NULL,quarter VARCHAR(30) NOT NULL,the_year SMALLINT NOT NULL,store_sales DECIMAL(10,4) NOT NULL,store_cost DECIMAL(10,4) NOT NULL,unit_sales DECIMAL(10,4) NOT NULL,customer_count INTEGER NOT NULL,fact_count INTEGER NOT NULL);
CREATE TABLE agg_c_14_sales_fact_1997 (product_id INTEGER NOT NULL,customer_id INTEGER NOT NULL,store_id INTEGER NOT NULL,promotion_id INTEGER NOT NULL,month_of_year SMALLINT NOT NULL,quarter VARCHAR(30) NOT NULL,the_year SMALLINT NOT NULL,store_sales DECIMAL(10,4) NOT NULL,store_cost DECIMAL(10,4) NOT NULL,unit_sales DECIMAL(10,4) NOT NULL,fact_count INTEGER NOT NULL);
CREATE INDEX i_sls97c14cust ON agg_c_14_sales_fact_1997(customer_id);
CREATE INDEX i_sls97c14prod ON agg_c_14_sales_fact_1997(product_id);
CREATE INDEX i_sls97c14promo ON agg_c_14_sales_fact_1997(promotion_id);
CREATE INDEX i_sls97c14store ON agg_c_14_sales_fact_1997(store_id);
CREATE TABLE agg_c_special_sales_fact_1997 (product_id INTEGER NOT NULL,promotion_id INTEGER NOT NULL,customer_id INTEGER NOT NULL,store_id INTEGER NOT NULL,time_month SMALLINT NOT NULL,time_quarter VARCHAR(30) NOT NULL,time_year SMALLINT NOT NULL,store_sales_sum DECIMAL(10,4) NOT NULL,store_cost_sum DECIMAL(10,4) NOT NULL,unit_sales_sum DECIMAL(10,4) NOT NULL,fact_count INTEGER NOT NULL);
CREATE INDEX i_sls97speccust ON agg_c_special_sales_fact_1997(customer_id);
CREATE INDEX i_sls97specprod ON agg_c_special_sales_fact_1997(product_id);
CREATE INDEX i_sls97specpromo ON agg_c_special_sales_fact_1997(promotion_id);
CREATE INDEX i_sls97specstore ON agg_c_special_sales_fact_1997(store_id);
CREATE TABLE agg_g_ms_pcat_sales_fact_1997 (gender VARCHAR(30) NOT NULL,marital_status VARCHAR(30) NOT NULL,product_family VARCHAR(30),product_department VARCHAR(30),product_category VARCHAR(30),month_of_year SMALLINT NOT NULL,quarter VARCHAR(30) NOT NULL,the_year SMALLINT NOT NULL,store_sales DECIMAL(10,4) NOT NULL,store_cost DECIMAL(10,4) NOT NULL,unit_sales DECIMAL(10,4) NOT NULL,customer_count INTEGER NOT NULL,fact_count INTEGER NOT NULL);
CREATE INDEX i_sls97gmp_gender ON agg_g_ms_pcat_sales_fact_1997(gender);
CREATE INDEX i_sls97gmp_ms ON agg_g_ms_pcat_sales_fact_1997(marital_status);
CREATE INDEX i_sls97gmp_pfam ON agg_g_ms_pcat_sales_fact_1997(product_family);
CREATE INDEX i_sls97gmp_pdept ON agg_g_ms_pcat_sales_fact_1997(product_department);
CREATE INDEX i_sls97gmp_pcat ON agg_g_ms_pcat_sales_fact_1997(product_category);
CREATE INDEX i_sls97gmp_tmonth ON agg_g_ms_pcat_sales_fact_1997(month_of_year);
CREATE INDEX i_sls97gmp_tquarter ON agg_g_ms_pcat_sales_fact_1997(quarter);
CREATE INDEX i_sls97gmp_tyear ON agg_g_ms_pcat_sales_fact_1997(the_year);
CREATE TABLE agg_l_03_sales_fact_1997 (time_id INTEGER NOT NULL,customer_id INTEGER NOT NULL,store_sales DECIMAL(10,4) NOT NULL,store_cost DECIMAL(10,4) NOT NULL,unit_sales DECIMAL(10,4) NOT NULL,fact_count INTEGER NOT NULL);
CREATE TABLE agg_l_04_sales_fact_1997 (time_id INTEGER NOT NULL,store_sales DECIMAL(10,4) NOT NULL,store_cost DECIMAL(10,4) NOT NULL,unit_sales DECIMAL(10,4) NOT NULL,customer_count INTEGER NOT NULL,fact_count INTEGER NOT NULL);
CREATE TABLE agg_l_05_sales_fact_1997 (product_id INTEGER NOT NULL,customer_id INTEGER NOT NULL,promotion_id INTEGER NOT NULL,store_id INTEGER NOT NULL,store_sales DECIMAL(10,4) NOT NULL,store_cost DECIMAL(10,4) NOT NULL,unit_sales DECIMAL(10,4) NOT NULL,fact_count INTEGER NOT NULL);
CREATE INDEX i_sls97l05cust ON agg_l_05_sales_fact_1997(customer_id);
CREATE INDEX i_sls97l05prod ON agg_l_05_sales_fact_1997(product_id);
CREATE INDEX i_sls97l05promo ON agg_l_05_sales_fact_1997(promotion_id);
CREATE INDEX i_sls97l05store ON agg_l_05_sales_fact_1997(store_id);
CREATE TABLE agg_lc_06_sales_fact_1997 (time_id INTEGER NOT NULL,city VARCHAR(30) NOT NULL,state_province VARCHAR(30) NOT NULL,country VARCHAR(30) NOT NULL,store_sales DECIMAL(10,4) NOT NULL,store_cost DECIMAL(10,4) NOT NULL,unit_sales DECIMAL(10,4) NOT NULL,fact_count INTEGER NOT NULL);
CREATE TABLE agg_lc_100_sales_fact_1997 (product_id INTEGER NOT NULL,customer_id INTEGER NOT NULL,quarter VARCHAR(30) NOT NULL,the_year SMALLINT NOT NULL,store_sales DECIMAL(10,4) NOT NULL,store_cost DECIMAL(10,4) NOT NULL,unit_sales DECIMAL(10,4) NOT NULL,fact_count INTEGER NOT NULL);
CREATE INDEX i_sls97lc100cust ON agg_lc_100_sales_fact_1997(customer_id);
CREATE INDEX i_sls97lc100prod ON agg_lc_100_sales_fact_1997(product_id);
CREATE TABLE agg_ll_01_sales_fact_1997 (product_id INTEGER NOT NULL,time_id INTEGER NOT NULL,customer_id INTEGER NOT NULL,store_sales DECIMAL(10,4) NOT NULL,store_cost DECIMAL(10,4) NOT NULL,unit_sales DECIMAL(10,4) NOT NULL,fact_count INTEGER NOT NULL);
CREATE INDEX i_sls97ll01cust ON agg_ll_01_sales_fact_1997(customer_id);
CREATE INDEX i_sls97ll01prod ON agg_ll_01_sales_fact_1997(product_id);
CREATE INDEX i_sls97ll01time ON agg_ll_01_sales_fact_1997(time_id);
CREATE TABLE agg_pl_01_sales_fact_1997 (product_id INTEGER NOT NULL,time_id INTEGER NOT NULL,customer_id INTEGER NOT NULL,store_sales_sum DECIMAL(10,4) NOT NULL,store_cost_sum DECIMAL(10,4) NOT NULL,unit_sales_sum DECIMAL(10,4) NOT NULL,fact_count INTEGER NOT NULL);
CREATE INDEX i_sls97pl01cust ON agg_pl_01_sales_fact_1997(customer_id);
CREATE INDEX i_sls97pl01prod ON agg_pl_01_sales_fact_1997(product_id);
CREATE INDEX i_sls97pl01time ON agg_pl_01_sales_fact_1997(time_id);
CREATE TABLE category (category_id VARCHAR(30) NOT NULL,category_parent VARCHAR(30),category_description VARCHAR(30) NOT NULL,category_rollup VARCHAR(30));
CREATE UNIQUE INDEX i_category_id ON category(category_id);
CREATE INDEX i_category_parent ON category(category_parent);
CREATE TABLE currency (currency_id INTEGER NOT NULL,date DATE NOT NULL,currency VARCHAR(30) NOT NULL,conversion_ratio DECIMAL(10,4) NOT NULL);
CREATE UNIQUE INDEX i_currency ON currency(currency_id,date);
CREATE TABLE customer (customer_id INTEGER NOT NULL,account_num BIGINT NOT NULL,lname VARCHAR(30) NOT NULL,fname VARCHAR(30) NOT NULL,mi VARCHAR(30),address1 VARCHAR(30),address2 VARCHAR(30),address3 VARCHAR(30),address4 VARCHAR(30),city VARCHAR(30),state_province VARCHAR(30),postal_code VARCHAR(30) NOT NULL,country VARCHAR(30) NOT NULL,customer_region_id INTEGER NOT NULL,phone1 VARCHAR(30) NOT NULL,phone2 VARCHAR(30) NOT NULL,birthdate DATE NOT NULL,marital_status VARCHAR(30) NOT NULL,yearly_income VARCHAR(30) NOT NULL,gender VARCHAR(30) NOT NULL,total_children SMALLINT NOT NULL,num_children_at_home SMALLINT NOT NULL,education VARCHAR(30) NOT NULL,date_accnt_opened DATE NOT NULL,member_card VARCHAR(30),occupation VARCHAR(30),houseowner VARCHAR(30),num_cars_owned INTEGER,fullname VARCHAR(60) NOT NULL);
CREATE UNIQUE INDEX i_customer_id ON customer(customer_id);
CREATE INDEX i_cust_acct_num ON customer(account_num);
CREATE INDEX i_customer_fname ON customer(fname);
CREATE INDEX i_customer_lname ON customer(lname);
CREATE INDEX i_cust_child_home ON customer(num_children_at_home);
CREATE INDEX i_cust_postal_code ON customer(postal_code);
CREATE INDEX i_cust_region_id ON customer(customer_region_id);
CREATE TABLE days (day INTEGER NOT NULL,week_day VARCHAR(30) NOT NULL);
CREATE TABLE department (department_id INTEGER NOT NULL,department_description VARCHAR(30) NOT NULL);
CREATE UNIQUE INDEX i_department_id ON department(department_id);
CREATE TABLE employee (employee_id INTEGER NOT NULL,full_name VARCHAR(30) NOT NULL,first_name VARCHAR(30) NOT NULL,last_name VARCHAR(30) NOT NULL,position_id INTEGER,position_title VARCHAR(30),store_id INTEGER NOT NULL,department_id INTEGER NOT NULL,birth_date DATE NOT NULL,hire_date TI