Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[Database|MySQL] Using the star_schema_mysql_scripts.sql file, generate your data warehouse on the MYSQL environment. Include a screenshot as a proof of your data warehouse installation. Here

[Database|MySQL] Using the star_schema_mysql_scripts.sql file, generate your data warehouse on the MYSQL environment. Include a screenshot as a proof of your data warehouse installation. Here is the code we are supposed to use:

CREATE TABLE dimcustomer

(

customerid int,

customeraltid varchar(10) not null,

customername varchar(50),

gender varchar(20),

PRIMARY KEY (customerid)

)

INSERT INTO dimcustomer(customerid,customeraltid,customername,gender) VALUES

(1,'IMI-001','Henry Ford','M'),

(2,'IMI-002','Bill Gates','M'),

(3,'IMI-003','Muskan Shaikh','F'),

(4,'IMI-004','Richard Thrubin','M'),

(5,'IMI-005','Emma Wattson','F');

CREATE TABLE dimproduct

(

productkey int,

productaltkey varchar(10) NOT NULL,

productname varchar(100),

productactualcost DECIMAL(10,2),

productsalescost DECIMAL(10,2),

PRIMARY KEY(productkey)

)

INSERT INTO dimproduct(productkey,productaltkey,productname,productactualcost, productsalescost) VALUES

(1,'ITM-001','Wheat Floor 1kg',5.50,6.50),

(2,'ITM-002','Rice Grains 1kg',22.50,24),

(3,'ITM-003','SunFlower Oil 1 ltr',42,43.5),

(4,'ITM-004','Nirma Soap',18,20),

(5,'ITM-005','Arial Washing Powder 1kg',135,139);

CREATE TABLE dimstore

(

storeid int,

storealtid varchar(10) NOT NULL,

storename varchar(100),

storelocation varchar(100),

city varchar(100),

state varchar(100),

country varchar(100),

PRIMARY KEY(storeid)

)

INSERT INTO dimstore(storeid, storealtid,storename,storelocation,city,state,country) VALUES

(1,'LOC-A1','X-Mart','S.P. RingRoad','Ahmedabad','Guj','India'),

(2,'LOC-A2','X-Mart','Maninagar','Ahmedabad','Guj','India'),

(3,'LOC-A3','X-Mart','Sivranjani','Ahmedabad','Guj','India');

CREATE TABLE dimsalesperson

(

salespersonid int,

salespersonaltid varchar(10) NOT NULL,

salespersonname varchar(100),

storeid int,

city varchar(100),

state varchar(100),

country varchar(100),

PRIMARY KEY(salespersonid)

)

INSERT INTO dimsalesperson(salespersonid, salespersonaltid,salespersonname,storeid,city,state,country ) VALUES

(1,'SP-DMSPR1','Ashish',1,'Ahmedabad','Guj','India'),

(2,'SP-DMSPR2','Ketan',1,'Ahmedabad','Guj','India'),

(3,'SP-DMNGR1','Srinivas',2,'Ahmedabad','Guj','India'),

(4,'SP-DMNGR2','Saad',2,'Ahmedabad','Guj','India'),

(5,'SP-DMSVR1','Jasmin',3,'Ahmedabad','Guj','India'),

(6,'SP-DMSVR2','Jacob',3,'Ahmedabad','Guj','India');

CREATE TABLE factproductsales

(

transactionid BIGINT AUTO_INCREMENT,

salesinvoicenumber int NOT NULL,

salesdatekey INT,

salesyearkey INT,

salesmonthkey INT,

salesdayKey INT,

storeid INT NOT NULL,

customerid INT NOT NULL,

productid INT NOT NULL,

salespersonid INT NOT NULL,

quantity float,

salestotalcost DECIMAL(10,2),

productactualcost DECIMAL(10,2),

PRIMARY KEY(transactionid)

)

AlTER TABLE factproductsales

ADD FOREIGN KEY (storeid) REFERENCES dimstore(storeid);

AlTER TABLE factproductsales

ADD FOREIGN KEY (customerid) REFERENCES dimcustomer(customerid);

AlTER TABLE factproductsales

ADD FOREIGN KEY (productid) REFERENCES dimproduct(productkey);

AlTER TABLE factproductsales

ADD FOREIGN KEY (salespersonid) REFERENCES dimsalesperson(salespersonid);

INSERT INTO factproductsales(salesinvoicenumber,salesdatekey,salesyearkey,salesmonthkey,salesdaykey,storeid,customerid,productid,salespersonid,quantity,productactualcost,salestotalcost) VALUES

(1,20130101,2013,01,01,1,1,1,1,2,11,13),

(1,20130101,2013,01,01,1,1,2,1,1,22.50,24),

(1,20130101,2013,01,01,1,1,3,1,1,42,43.5),

(2,20130101,2013,01,01,1,2,3,1,1,42,43.5),

(2,20130101,2013,01,01,1,2,4,1,3,54,60),

(3,20130101,2013,01,01,1,3,2,2,2,11,13),

(3,20130101,2013,01,01,1,3,3,2,1,42,43.5),

(3,20130101,2013,01,01,1,3,4,2,3,54,60),

(3,20130101,2013,01,01,1,3,5,2,1,135,139)

INSERT INTO factproductsales(salesinvoicenumber,salesdatekey,salesyearkey,salesmonthkey,salesdaykey,storeid,customerid,productid,salespersonid,quantity,productactualcost,salestotalcost) VALUES

(4,20130102,2013,01,02,1,1,1,1,2,11,13),

(4,20130102,2013,01,02,1,1,2,1,1,22.50,24),

(5,20130102,2013,01,02,1,2,3,1,1,42,43.5),

(5,20130102,2013,01,02,1,2,4,1,3,54,60),

(6,20130102,2013,01,02,1,3,2,2,2,11,13),

(6,20130102,2013,01,02,1,3,5,2,1,135,139),

(7,20130102,2013,01,02,2,1,4,3,3,54,60),

(7,20130102,2013,01,02,2,1,5,3,1,135,139)

INSERT INTO factproductsales(salesinvoicenumber,salesdatekey,salesyearkey,salesmonthkey,salesdaykey,storeid,customerid,productid,salespersonid,quantity,productactualcost,salestotalcost) VALUES

(8,20130103,2013,01,03,1,1,3,1,2,84,87),

(8,20130103,2013,01,03,1,1,4,1,3,54,60),

(9,20130103,2013,01,03,1,2,1,1,1,5.5,6.5),

(9,20130103,2013,01,03,1,2,2,1,1,22.50,24),

(10,20130103,2013,01,03,1,3,1,2,2,11,13),

(10,20130103,2013,01,03,1,3,4,2,3,54,60),

(11,20130103,2013,01,03,2,1,2,3,1,5.5,6.5),

(11,20130103,2013,01,03,2,1,3,3,1,42,43.5)

Here are the questions

b) [10 pts] What is the profit and name of the product id 4 in Jan 2 2013?

c) [10 pts] What is each product's total sales in Jan 1 2013?

d) [10 pts] Which product (id and name) has the highest sales in Jan 1 2013?

e) [10 pts] What are the total sales of each store?

f) [10 pts] Which store location has the highest sales?

g) [Bonus- 5pts] How many distinct customers does the X-Mart have in 2013?

h) [Bonus 5pts] Which gender of customers buys less in 2013?

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

Database Processing

Authors: David M. Kroenke

12th Edition International Edition

1292023422, 978-1292023427

More Books

Students also viewed these Databases questions

Question

b. Will there be one assigned leader?

Answered: 1 week ago