Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CREATE TABLE Mailshot_Campaigns ( mailshot_id int NOT NULL, product_category_code varchar(45), mailshot_name varchar(45), mailshot_start_date datetime, mailshot_end_date datetime, mailshot_target_population NTEXT , mailshot_objectives varchar(250), other_mailshot_details varchar(250), PRIMARY KEY

image text in transcribed

CREATE TABLE Mailshot_Campaigns ( mailshot_id int NOT NULL, product_category_code varchar(45), mailshot_name varchar(45), mailshot_start_date datetime, mailshot_end_date datetime, mailshot_target_population NTEXT , mailshot_objectives varchar(250), other_mailshot_details varchar(250), PRIMARY KEY (mailshot_id) );

CREATE TABLE Product_Promotions ( promotion_id int NOT NULL, promotion_start_date datetime, promotion_end_date datetime, promotion_name varchar(45), promotion_description varchar(250), other_promotion_detail varchar(250), PRIMARY KEY (promotion_id) );

CREATE TABLE Ref_Calender ( time_period_id int NOT NULL, day_number datetime, hour_number datetime, day_date datetime, PRIMARY KEY (time_period_id) );

CREATE TABLE Ref_Invoice_Status_Codes ( invoice_status_code int NOT NULL, invoice_status_description varchar(250), PRIMARY KEY (invoice_status_code) );

CREATE TABLE Ref_Payment_Methods( payment_method_code int NOT NULL, payment_method_description varchar(250), PRIMARY KEY (payment_method_code) );

CREATE TABLE Stores( store_id int NOT NULL, store_name varchar(45), store_address varchar(250), other_store_detail varchar(250), PRIMARY KEY (store_id) );

CREATE TABLE Job_Details( job_id int NOT NULL, PRIMARY KEY (job_id) );

CREATE TABLE Staff( staff_id int NOT NULL, job_title_id int, report_to_staff_id int, store_id int, staff_name varchar(45), staff_address varchar(250), other_staff_details varchar(250), PRIMARY KEY (staff_id), FOREIGN KEY (job_title_id) REFERENCES Job_Details(job_id), FOREIGN KEY (report_to_staff_id) REFERENCES Staff(staff_id), FOREIGN KEY (store_id) REFERENCES Stores(store_id) );

CREATE TABLE Retail_Dimensional_Model( fact_id int NOT NULL, invoice_status_code int, mailshot_id int, product_id int, promotion_id int, payment_method_code int, staff_id int, store_id int, time_period_id int, totals decimal(10,2), average_counts_total decimal(10,2), other_derived_figures decimal(10,2), PRIMARY KEY (fact_id), FOREIGN KEY (invoice_status_code) REFERENCES Ref_Invoice_Status_Codes(invoice_status_code), FOREIGN KEY (mailshot_id) REFERENCES Mailshot_Campaigns(mailshot_id), FOREIGN KEY (promotion_id) REFERENCES Product_Promotions(promotion_id), FOREIGN KEY (payment_method_code) REFERENCES Ref_Payment_Methods(payment_method_code), FOREIGN KEY (staff_id) REFERENCES Staff(staff_id), FOREIGN KEY (store_id) REFERENCES Stores(store_id), FOREIGN KEY (time_period_id) REFERENCES Ref_Calender(time_period_id) );

CREATE TABLE Products_in_Warehouses ( product_id int NOT NULL, warehouse_id int, parent_product_id int , product_name varchar(45), product_price decimal(10,2), product_color varchar(45), product_size varchar(45), product_description varchar(250), other_product_detail varchar(250), PRIMARY KEY (product_id), FOREIGN KEY (warehouse_id) REFERENCES Retail_Dimensional_Model(fact_id) );

ALTER TABLE Retail_Dimensional_Model ADD FOREIGN KEY (product_id) REFERENCES Products_in_warehouses (product_id);

CREATE UNIQUE INDEX staff_report_index ON staff( report_to_staff_id);

SELECT product_id, product_name, product_color, SUM(product_price) as total FROM Products_in_Warehouses GROUP BY CUBE(product_id, product_name, product_color);

-----------------------------------------------------------------------------

Q.Apply this code in SQL and complete follwing:

-Insert values for tables

- Add one index,cube query for each tables

**if done secreenshot output

A Retail Dimensional Model Ret Calendar PK ti me period id day number Mall shot Campaign hour number PK mailshot id day date product category code malahot name malahot 8tart dates maishot end date mailshat target ulation Retail Dimensional Model maishot objectives other malahot detalla PK fact Udl invoice status code Products in Warehouses FK product id FK promotioLid PF product Id FK payment method code FAX warehouse id FR slam id parent product. d er FAT store id product name product price totals product calo averages, counts, balas product size her figures product description other product datala Ref Invoice Status Codes Product Promotion PK invoice status code PK Promotio invoice Btatue deecnpton promotion start date promotion end date promotion name promotion description other promotion details Data Base Answers Ltd. 2013 Statt PK staff id FK job id FK reporta to atar FAT store id staff name staff address other staff details Stores PK store id store name store adress other stone details. Ref Payment Methods Ph payment method code payment method description

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

More Books

Students also viewed these Databases questions