#DBM 449 Laboratory Procedures iLab 6 Answers
Explore tagged Tumblr posts
Text
DBM 449 Laboratory Procedures iLab 6 Answers
Follow Below Link to Download Tutorial
https://homeworklance.com/downloads/dbm-449-laboratory-procedures-ilab-6-answers/
For More Information Visit Our Website ( https://homeworklance.com/ )
Email us At: [email protected] or [email protected]
I. OBJECTIVES
Understand and become familiar with the SQL Analytical Extensions.
Learn to create, use, and maintain materialized views, and their functional equivalents.
Effectively apply Advanced Aggregate SQL Operations, such as GROUP BY ROLLUP to solve business intelligence questions and analytical processing problems.
II. PARTS LIST
EDUPE-VT Omnymbus Virtual Machine Environment (https://devry.edupe.net:9090/) and/or:
MySQL (dev.mysql.com/downloads)
III. PROCEDURE
Scenario and Summary
For the lab this week, we are going to look at how the ROLLUP and CUBE extensions available in SQL can be used to create query result sets that have more than one dimension to them. Both of these extensions are used in conjunction with the GROUP BY clause and allow for a much broader look at the data.
To record your work for this lab use the lab report found at the end of this document. As in your previous labs, you will need to copy/paste your SQL statements and results into this document. Upon completion and prior to the due date, submit this document to the appropriate Dropbox.
iLAB STEPS
STEP 1: Setting Up
For this lab you will be using a different user and set of tables than you have used so far for other labs. To set up your instance you will need to do the following.
The first thing you will do for this lab is to run the following SQL Script. Begin by creating the DBM449Lab6 Schema, and creating any user accounts and privileges you wish to use (at least one).
Run the following script to create and populate a set of tables that will be used for this lab. Instructions for this are outlined in Step 1.
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=’TRADITIONAL,ALLOW_INVALID_DATES’;
USE `DBM449Lab6` ;
— —————————————————–
— Table `DBM449Lab6`.`DISTRICT`
— —————————————————–
DROP TABLE IF EXISTS `DBM449Lab6`.`DISTRICT` ;
CREATE TABLE IF NOT EXISTS `DBM449Lab6`.`DISTRICT` (
`DIST_ID` INT(11) NOT NULL,
`DIST_NAME` VARCHAR(10) NULL DEFAULT NULL,
PRIMARY KEY (`DIST_ID`))
ENGINE = InnoDB;
— —————————————————–
— Table `DBM449Lab6`.`CUSTOMER`
— —————————————————–
DROP TABLE IF EXISTS `DBM449Lab6`.`CUSTOMER` ;
CREATE TABLE IF NOT EXISTS `DBM449Lab6`.`CUSTOMER` (
`CUST_CODE` DECIMAL(10,0) NOT NULL,
`CUST_LNAME` VARCHAR(15) NULL DEFAULT NULL,
`CUST_FNAME` VARCHAR(15) NULL DEFAULT NULL,
`CUST_INITIAL` CHAR(1) NULL DEFAULT NULL,
`CUST_STATE` CHAR(2) NULL DEFAULT NULL,
`DIST_ID` INT(11) NOT NULL,
PRIMARY KEY (`CUST_CODE`),
CONSTRAINT `fk_CUSTOMER_DISTRICT1`
FOREIGN KEY (`DIST_ID`)
REFERENCES `DBM449Lab6`.`DISTRICT` (`DIST_ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
CREATE INDEX `fk_CUSTOMER_DISTRICT1_idx` ON `DBM449Lab6`.`CUSTOMER` (`DIST_ID` ASC);
— —————————————————–
— Table `DBM449Lab6`.`SUPPLIER`
— —————————————————–
DROP TABLE IF EXISTS `DBM449Lab6`.`SUPPLIER` ;
CREATE TABLE IF NOT EXISTS `DBM449Lab6`.`SUPPLIER` (
`SUP_CODE` INT(11) NOT NULL,
`SUP_NAME` VARCHAR(35) NULL DEFAULT NULL,
`SUP_AREACODE` CHAR(3) NULL DEFAULT NULL,
`SUP_STATE` CHAR(2) NULL DEFAULT NULL,
PRIMARY KEY (`SUP_CODE`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
— —————————————————–
— Table `DBM449Lab6`.`PRODUCT`
— —————————————————–
DROP TABLE IF EXISTS `DBM449Lab6`.`PRODUCT` ;
CREATE TABLE IF NOT EXISTS `DBM449Lab6`.`PRODUCT` (
`PROD_CODE` VARCHAR(10) NOT NULL,
`PROD_DESCRIPT` VARCHAR(35) NULL DEFAULT NULL,
`PROD_CATEGORY` VARCHAR(5) NULL DEFAULT NULL,
`SUP_CODE` INT(11) NOT NULL,
PRIMARY KEY (`PROD_CODE`),
CONSTRAINT `fk_PRODUCT_SUPPLIER`
FOREIGN KEY (`SUP_CODE`)
REFERENCES `DBM449Lab6`.`SUPPLIER` (`SUP_CODE`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
CREATE INDEX `fk_PRODUCT_SUPPLIER_idx` ON `DBM449Lab6`.`PRODUCT` (`SUP_CODE` ASC);
— —————————————————–
— Table `DBM449Lab6`.`SALES`
— —————————————————–
DROP TABLE IF EXISTS `DBM449Lab6`.`SALES` ;
CREATE TABLE IF NOT EXISTS `DBM449Lab6`.`SALES` (
`TIME_ID` DECIMAL(10,0) NOT NULL DEFAULT ‘0’,
`CUST_CODE` DECIMAL(10,0) NOT NULL DEFAULT ‘0’,
`PROD_CODE` VARCHAR(10) NOT NULL DEFAULT ”,
`SALE_UNITS` DECIMAL(10,0) NULL DEFAULT NULL,
`SALE_PRICE` DECIMAL(10,2) NULL DEFAULT NULL,
PRIMARY KEY (`TIME_ID`, `CUST_CODE`, `PROD_CODE`))
ENGINE = InnoDB;
— —————————————————–
— Table `DBM449Lab6`.`TIME`
— —————————————————–
DROP TABLE IF EXISTS `DBM449Lab6`.`TIME` ;
CREATE TABLE IF NOT EXISTS `DBM449Lab6`.`TIME` (
`TIME_ID` INT(11) NOT NULL,
`TIME_YEAR` INT(11) NULL DEFAULT NULL,
`TIME_MONTH` INT(11) NULL DEFAULT NULL,
`TIME_DAY` INT(11) NULL DEFAULT NULL,
`TIME_QTR` INT(11) NULL DEFAULT NULL,
PRIMARY KEY (`TIME_ID`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
INSERT INTO SUPPLIER VALUES(31225,’Bryson, Inc.’ ,’615′,’TN’);
INSERT INTO SUPPLIER VALUES(31226,’SuperLoo, Inc.’ ,’904′,’FL’);
INSERT INTO SUPPLIER VALUES(31231,’DE Supply’ ,’615′,’TN’);
INSERT INTO SUPPLIER VALUES(31344,’Gomez Bros.’ ,’615′,’KY’);
INSERT INTO SUPPLIER VALUES(32567,’Dome Supply’ ,’901′,’GA’);
INSERT INTO SUPPLIER VALUES(33119,’Randsets Ltd.’ ,’901′,’GA’);
INSERT INTO SUPPLIER VALUES(44004,’Brackman Bros.’ ,’615′,’TN’);
INSERT INTO SUPPLIER VALUES(44288,’ORDVA, Inc.’ ,’615′,’TN’);
INSERT INTO SUPPLIER VALUES(55443,’BK, Inc.’ ,’904′,’FL’);
INSERT INTO SUPPLIER VALUES(55501,’Damal Supplies’ ,’615′,’TN’);
INSERT INTO SUPPLIER VALUES(55595,’Rubicon Systems’ ,’904′,’FL’);
INSERT INTO PRODUCT VALUES(’11QER/31′,’Power painter, 15 psi., 3-nozzle’ ,’CAT1′,55595);
INSERT INTO PRODUCT VALUES(’13-Q2/P2′,’7.25-in. pwr. saw blade’ ,’CAT1′,31344);
INSERT INTO PRODUCT VALUES(’14-Q1/L3′,’9.00-in. pwr. saw blade’ ,’CAT1′,31344);
INSERT INTO PRODUCT VALUES(‘1546-QQ2′,’Hrd. cloth, 1/4-in., 2×50′ ,’CAT2’,33119);
INSERT INTO PRODUCT VALUES(‘1558-QW1′,’Hrd. cloth, 1/2-in., 3×50′ ,’CAT2’,33119);
INSERT INTO PRODUCT VALUES(‘2232/QTY’,’BD jigsaw, 12-in. blade’ ,’CAT2′,44288);
INSERT INTO PRODUCT VALUES(‘2232/QWE’,’BD jigsaw, 8-in. blade’ ,’CAT3′,44288);
INSERT INTO PRODUCT VALUES(‘2238/QPD’,’BD cordless drill, 1/2-in.’ ,’CAT3′,55595);
INSERT INTO PRODUCT VALUES(‘23109-HB’,’Claw hammer’ ,’CAT4′,31225);
INSERT INTO PRODUCT VALUES(‘23114-AA’,’Sledge hammer, 12 lb.’ ,’CAT4′,31225);
INSERT INTO PRODUCT VALUES(‘54778-2T’,’Rat-tail file, 1/8-in. fine’ ,’CAT1′,31344);
INSERT INTO PRODUCT VALUES(’89-WRE-Q’,’Hicut chain saw, 16 in.’ ,’CAT2′,44288);
INSERT INTO PRODUCT VALUES(‘PVC23DRT’,’PVC pipe, 3.5-in., 8-ft’ ,’CAT3′,31225);
INSERT INTO PRODUCT VALUES(‘SM-18277′,’1.25-in. metal screw, 25′ ,’CAT4’,31225);
INSERT INTO PRODUCT VALUES(‘SW-23116′,’2.5-in. wd. screw, 50′ ,’CAT2’,31231);
INSERT INTO PRODUCT VALUES(‘WR3/TT3′ ,’Steel matting, 4”x8”x1/6″, .5″ mesh’,’CAT3′,55595);
INSERT INTO DISTRICT VALUES(1,’NE’);
INSERT INTO DISTRICT VALUES(2,’NW’);
INSERT INTO DISTRICT VALUES(3,’SE’);
INSERT INTO DISTRICT VALUES(4,’SW’);
INSERT INTO CUSTOMER VALUES(110010,’Ramas’ ,’Alfred’,’A’ ,’TN’,3);
INSERT INTO CUSTOMER VALUES(110011,’Dunne’ ,’Leona’ ,’K’ ,’GA’,3);
INSERT INTO CUSTOMER VALUES(110012,’Smith’ ,’Kathy’ ,’W’ ,’NY’,1);
INSERT INTO CUSTOMER VALUES(110013,’Olowski’ ,’Paul’ ,’F’ ,’NJ’,1);
INSERT INTO CUSTOMER VALUES(110014,’Orlando’ ,’Myron’ ,NULL,’CO’,2);
INSERT INTO CUSTOMER VALUES(110015,’O”Brian’,’Amy’ ,’B’ ,’TN’,3);
INSERT INTO CUSTOMER VALUES(110016,’Brown’ ,’James’ ,’G’ ,’GA’,3);
INSERT INTO CUSTOMER VALUES(110017,’Williams’,’George’,NULL,’CA’,4);
INSERT INTO CUSTOMER VALUES(110018,’Farriss’ ,’Anne’ ,’G’ ,’CA’,4);
INSERT INTO CUSTOMER VALUES(110019,’Smith’ ,’Olette’,’K’ ,’CO’,2);
INSERT INTO TIME VALUES(201,2009,09,29,3);
INSERT INTO TIME VALUES(202,2009,09,30,3);
INSERT INTO TIME VALUES(203,2009,09,31,3);
INSERT INTO TIME VALUES(206,2009,10,03,4);
INSERT INTO TIME VALUES(207,2009,10,04,4);
INSERT INTO SALES VALUES(201,110014,’13-Q2/P2′,1,14.99);
INSERT INTO SALES VALUES(201,110014,’23109-HB’,1,11.95);
INSERT INTO SALES VALUES(201,110015,’54778-2T’,2,5.99);
INSERT INTO SALES VALUES(201,110015,’2238/QPD’,1,38.95);
INSERT INTO SALES VALUES(202,110016,’1546-QQ2′,1,311.95);
INSERT INTO SALES VALUES(202,110016,’13-Q2/P2′,5,15.99);
INSERT INTO SALES VALUES(202,110017,’54778-2T’,3,5.99);
INSERT INTO SALES VALUES(202,110017,’23109-HB’,2,11.95);
INSERT INTO SALES VALUES(202,110018,’PVC23DRT’,12,5.87);
INSERT INTO SALES VALUES(203,110012,’SM-18277′,3,8.95);
INSERT INTO SALES VALUES(203,110014,’2232/QTY’,1,109.92);
INSERT INTO SALES VALUES(203,110015,’23109-HB’,1,11.95);
INSERT INTO SALES VALUES(203,110015,’89-WRE-Q’,1,258.95);
INSERT INTO SALES VALUES(203,110016,’13-Q2/P2′,2,15.99);
INSERT INTO SALES VALUES(203,110016,’54778-2T’,1,5.99);
INSERT INTO SALES VALUES(203,110016,’PVC23DRT’,5,5.87);
INSERT INTO SALES VALUES(203,110017,’WR3/TT3′,3,111.95);
INSERT INTO SALES VALUES(203,110017,’23109-HB’,1,11.95);
INSERT INTO SALES VALUES(203,110017,’13-Q2/P2′,1,15.99);
INSERT INTO SALES VALUES(203,110018,’23109-HB’,1,11.95);
INSERT INTO SALES VALUES(203,110018,’54778-2T’,2,5.99);
INSERT INTO SALES VALUES(203,110018,’2238/QPD’,1,38.95);
INSERT INTO SALES VALUES(203,110019,’1546-QQ2′,1,311.95);
INSERT INTO SALES VALUES(206,110010,’13-Q2/P2′,5,15.99);
INSERT INTO SALES VALUES(206,110010,’54778-2T’,3,5.99);
INSERT INTO SALES VALUES(206,110010,’23109-HB’,2,11.95);
INSERT INTO SALES VALUES(206,110010,’PVC23DRT’,12,5.87);
INSERT INTO SALES VALUES(206,110011,’SM-18277′,3,8.95);
INSERT INTO SALES VALUES(206,110011,’2232/QTY’,1,109.92);
INSERT INTO SALES VALUES(206,110012,’23109-HB’,1,11.95);
INSERT INTO SALES VALUES(206,110012,’89-WRE-Q’,1,258.95);
INSERT INTO SALES VALUES(207,110013,’13-Q2/P2′,2,15.99);
INSERT INTO SALES VALUES(207,110013,’54778-2T’,1,5.99);
INSERT INTO SALES VALUES(207,110013,’PVC23DRT’,5,5.87);
INSERT INTO SALES VALUES(207,110014,’WR3/TT3′,3,111.95);
INSERT INTO SALES VALUES(207,110015,’23109-HB’,1,11.95);
Once the script has finished running, then issue a SHOW TABLES; sql statement. Make sure that you see the following tables listed.
STEP 2: Using the ROLLUP Extension
In this section of the lab you are going to create a sales report that will show a supplier code, product code and the total sales for each product based on unit price times a quantity. More importantly the column that shows the total sales will also show a grand total for the supplier as well as a grand total over all (this will be the last row of data shown). To do this you will use the ROLLUP extension as part of the GROUP BY clause in the query. Use aliases for the column names so that the output columns in the result set look like the following.
SUPPLIER CODE
PRODUCT
TOTAL SALES
31225
23109-HB
119.50
31225
PVC23DRT
199.58
31225
SM-18277
53.70
31225
372.78
31344
13-Q2/P2
254.84
31344
54778-2T
71.88
31344
326.72
33119
1546-QQ2
623.90
33119
623.90
44288
2232/QTY
219.84
44288
89-WRE-Q
517.90
44288
737.74
55595
2238/QPD
77.90
55595
WR3/TT3
671.70
55595
749.60
2810.74
Be sure to copy your SQL code and the result set produced and paste it into the appropriate place in the LAB6_REPORT.
STEP 3: Using the CUBE Extension
In this section of the lab you are going to examine the creation of a sales report that will show a month code, product code and the total sales for each product based on unit price times a quantity. At the time of this writing, MySQL does not implement the CUBE clause, so we will study an example constructed using the ORACLE DBMS. In this report, the column that shows the total sales will also show a subtotal for each month (in this case representing a quarter). Following the monthly totals for each product and the subtotal by month then the report will list a total for each product sold during the period with a grand total for all sales during the period (this will be the last row of data shown). To do this, the CUBE extension is used as part of the GROUP BY clause in the query. Aliases are used for the column names so that the output columns in the result set look like the following.
MONTH PRODUCT TOTAL SALES
———- ———- ———–
9 13-Q2/P2 142.91
9 1546-QQ2 623.9
9 2232/QTY 109.92
9 2238/QPD 77.9
9 23109-HB 71.7
9 54778-2T 47.92
9 89-WRE-Q 258.95
9 PVC23DRT 99.79
9 SM-18277 26.85
9 WR3/TT3 335.85
9 1795.69
MONTH PRODUCT TOTAL SALES
———- ———- ———–
10 13-Q2/P2 111.93
10 2232/QTY 109.92
10 23109-HB 47.8
10 54778-2T 23.96
10 89-WRE-Q 258.95
10 PVC23DRT 99.79
10 SM-18277 26.85
10 WR3/TT3 335.85
10 1015.05
13-Q2/P2 254.84
1546-QQ2 623.9
MONTH PRODUCT TOTAL SALES
———- ———- ———–
2232/QTY 219.84
2238/QPD 77.9
23109-HB 119.5
54778-2T 71.88
89-WRE-Q 517.9
PVC23DRT 199.58
SM-18277 53.7
WR3/TT3 671.7
2810.74
31 rows selected.
Here is the ORACLE PL/SQL query which generated these results. Please study the example carefully.
SQL> SELECT T.TIME_MONTH AS “MONTH”, P.PROD_COD
2 SUM(S.SALE_UNITS*S.SALE_PRICE) AS “TOTAL S
3 FROM SALES S, PRODUCT P, TIME T
4 WHERE S.TIME_ID = T.TIME_ID
5 AND S.PROD_CODE = P.PROD_CODE
6 GROUP BY CUBE (T.TIME_MONTH, P.PROD_CODE)
7 ORDER BY T.TIME_MONTH, P.PROD_CODE;
NOTE: This query will produce the same results using NATURAL JOIN.
SELECT TIME_MONTH AS “MONTH”, PROD_CODE AS “PRODUCT”, SUM(SALE_UNITS*SALE_PRICE) AS “TOTAL SALES”
FROM TIME NATURAL JOIN SALES NATURAL JOIN PRODUCT
GROUP BY CUBE (TIME_MONTH, PROD_CODE)
ORDER BY TIME_MONTH, PROD_CODE;
Notice that this report uses the SALES, PRODUCT and TIME tables. It is also possible to write the query using NATURAL JOIN but some developers may feel more comfortable using a traditional JOIN method that will work just as well. Notice that the grand total amount of 2810.74 is the same total as in step 2.
CHECKPOINT QUESTION: Research Data Warehouse Solutions that may be integrated into MySQL enterprise architecture (e.g., PENTAHO). Explain how these solutions may be employed to overcome the current limitations in MySQL support for OLAP functionality. Pay special attention to the reporting and analytic capabilities of these solutions. Based on your analysis and research, do you believe that analytic functions such as GROUP BY CUBE are best implemented in the database (MySQL), the Data Warehouse and Reporting Engine (e.g., PENTAHO), or both. Fully explain your analysis and conclusions.
STEP 4: Materialized Views and a Refresh Procedure
Materialized views (MVs), sometimes referred to as snapshots are a very important aspect of dealing with data when doing data mining or working with a data warehouse. Unlike regular views, a materialized view does not always automatically react to changes made in the base tables of the view. In database systems that directly implement MVs, a Materialized View Log must be created on each base table that will be used in the view. As discussed and explored briefly at the conclusion of Lab 5, MySQL does not directly implement materialized views, but these may be effectively emulated using tables constructed with the same attributes as the view, provided that steps are taken to ensure the automatic update or refresh of the table. For instructional purposes, we will accomplish this by the simple expedient of creating a stored procedure which will drop, recreate, and rebuild the table serving as the view. In our exploration of the concept of the materialized view, we are going to create we are going to use the TIME and the SALES tables.
Because we will emulate an MV in our solution, we will craft a stored procedure to update the MV.
Create and install a stored procedure, named REFRESH_MV_SALESBYMONTH, using the following SQL SELECT statement to guide you. This SELECT statement demonstrates the data to be selected to populate the table. Your stored procedure must: (1) drop the table if it exists; and (2) SELECT INTO the table MV_SALESBYMONTH to create and populate it. Note that, with this logic, no separate logic is needed to first create the view—simply run the stored procedure. The details of the implementation are left to you.
SELECT TIME_YEAR AS “YEAR”, TIME_MONTH AS “MONTH”, PROD_CODE AS “PRODUCT”,
SUM(SALE_UNITS) AS “UNITS SOLD”, SUM(SALE_UNITS*SALE_PRICE) AS “SALES TOTAL”
FROM TIME T, SALES S
WHERE S.TIME_ID = T.TIME_ID
GROUP BY TIME_YEAR, TIME_MONTH, PROD_CODE;
Be sure to copy your SQL code and the result set produced and paste it into the appropriate place in the LAB6_REPORT.
STEP 5: Using the Materialized View
First, CALL REFRESH_MV_SALESBYMONTH. This will make sure that the view is created, and currently up-to-date.
Run the SQL statement: SELECT * FROM MV_SALESBYMONTH. The output columns from your view should look similar to the following (use aliases to format the column headings) and you should have 18 rows in the result set.
YEAR MONTH PRODUCT CO UNITS SOLD SALES TOTAL
Now we are going to add some data and update the view. Remember, we must manually run the stored procedure to update the view, as it will not (yet!) automatically itself.
To begin with, insert the following data into the SALES table—(207, 110016, ‘SM-18277’,1,8.95).
CALL the stored procedure to refresh the view.
Query the view once again.
You should now see that the row for units sold in month 10 for SM-18277 has increased from 3 to 4 and total sales amount has gone from 26.85 to 35.80.
Delete the row you just added to the SALES table, and call the stored procedure to refresh the view, proving that things are up-to-date.
Create a Trigger on the SALES table so that any insert automatically fires off the stored procedure to update the view.
Test your trigger, by again inserting the following data into the SALES table—(207, 110016, ‘SM-18277’,1,8.95).
Query the view once again.
You should now see that the row for units sold in month 10 for SM-18277 has increased from 3 to 4 and total sales amount has gone from 26.85 to 35.80.
CHECKPOINT QUESTION: For instructional purposes and simplicity, we have indulged in the expedient of dropping and recreating the entire MV_SALESBYMONTH table, which now occurs each time a new record is inserted on the SALES table. Would this be unacceptable in practice? Explain why or why not. What other events, and what other tables would require wire-up of triggers in order to ensure that the view is kept up-to-date at all times?
Be sure to copy your SQL code and the result set produced and paste it into the appropriate place in the LAB6_REPORT.
Laboratory Report DeVry University College of Engineering and Information Sciences
Course Number: DBM449
Laboratory Number: 3
Laboratory Title: SWL Analytical Extensions & Materialized Views
Note: There is no limit on how much information you will enter under the three topics below. It is important to be clear and complete with your comments. Like a scientist you are documenting your progress in this week’s lab experiment.
Objectives: (In your own words what was this lab designed to accomplish? What was its purpose?)
Results: (Discuss the steps you used to complete your lab. Were you successful? What did you learn? What were the results? Explain what you did to accomplish each step. You can include screen shots, code listings, and so on. to clearly explain what you did. Be sure to record all results specifically directed by the lab procedure. Number all results to reflect the procedure number to which they correspond.)
Conclusions: (After completing this lab, in your own words, what conclusions can you draw from this experience?)
0 notes
Text
DBM 449 Laboratory Procedures iLab 6 Answers
Follow Below Link to Download Tutorial
https://homeworklance.com/downloads/dbm-449-laboratory-procedures-ilab-6-answers/
For More Information Visit Our Website ( https://homeworklance.com/ )
Email us At: [email protected] or [email protected]
I. OBJECTIVES
Understand and become familiar with the SQL Analytical Extensions.
Learn to create, use, and maintain materialized views, and their functional equivalents.
Effectively apply Advanced Aggregate SQL Operations, such as GROUP BY ROLLUP to solve business intelligence questions and analytical processing problems.
II. PARTS LIST
EDUPE-VT Omnymbus Virtual Machine Environment (https://devry.edupe.net:9090/) and/or:
MySQL (dev.mysql.com/downloads)
III. PROCEDURE
Scenario and Summary
For the lab this week, we are going to look at how the ROLLUP and CUBE extensions available in SQL can be used to create query result sets that have more than one dimension to them. Both of these extensions are used in conjunction with the GROUP BY clause and allow for a much broader look at the data.
To record your work for this lab use the lab report found at the end of this document. As in your previous labs, you will need to copy/paste your SQL statements and results into this document. Upon completion and prior to the due date, submit this document to the appropriate Dropbox.
iLAB STEPS
STEP 1: Setting Up
For this lab you will be using a different user and set of tables than you have used so far for other labs. To set up your instance you will need to do the following.
The first thing you will do for this lab is to run the following SQL Script. Begin by creating the DBM449Lab6 Schema, and creating any user accounts and privileges you wish to use (at least one).
Run the following script to create and populate a set of tables that will be used for this lab. Instructions for this are outlined in Step 1.
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=’TRADITIONAL,ALLOW_INVALID_DATES’;
USE `DBM449Lab6` ;
— —————————————————–
— Table `DBM449Lab6`.`DISTRICT`
— —————————————————–
DROP TABLE IF EXISTS `DBM449Lab6`.`DISTRICT` ;
CREATE TABLE IF NOT EXISTS `DBM449Lab6`.`DISTRICT` (
`DIST_ID` INT(11) NOT NULL,
`DIST_NAME` VARCHAR(10) NULL DEFAULT NULL,
PRIMARY KEY (`DIST_ID`))
ENGINE = InnoDB;
— —————————————————–
— Table `DBM449Lab6`.`CUSTOMER`
— —————————————————–
DROP TABLE IF EXISTS `DBM449Lab6`.`CUSTOMER` ;
CREATE TABLE IF NOT EXISTS `DBM449Lab6`.`CUSTOMER` (
`CUST_CODE` DECIMAL(10,0) NOT NULL,
`CUST_LNAME` VARCHAR(15) NULL DEFAULT NULL,
`CUST_FNAME` VARCHAR(15) NULL DEFAULT NULL,
`CUST_INITIAL` CHAR(1) NULL DEFAULT NULL,
`CUST_STATE` CHAR(2) NULL DEFAULT NULL,
`DIST_ID` INT(11) NOT NULL,
PRIMARY KEY (`CUST_CODE`),
CONSTRAINT `fk_CUSTOMER_DISTRICT1`
FOREIGN KEY (`DIST_ID`)
REFERENCES `DBM449Lab6`.`DISTRICT` (`DIST_ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
CREATE INDEX `fk_CUSTOMER_DISTRICT1_idx` ON `DBM449Lab6`.`CUSTOMER` (`DIST_ID` ASC);
— —————————————————–
— Table `DBM449Lab6`.`SUPPLIER`
— —————————————————–
DROP TABLE IF EXISTS `DBM449Lab6`.`SUPPLIER` ;
CREATE TABLE IF NOT EXISTS `DBM449Lab6`.`SUPPLIER` (
`SUP_CODE` INT(11) NOT NULL,
`SUP_NAME` VARCHAR(35) NULL DEFAULT NULL,
`SUP_AREACODE` CHAR(3) NULL DEFAULT NULL,
`SUP_STATE` CHAR(2) NULL DEFAULT NULL,
PRIMARY KEY (`SUP_CODE`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
— —————————————————–
— Table `DBM449Lab6`.`PRODUCT`
— —————————————————–
DROP TABLE IF EXISTS `DBM449Lab6`.`PRODUCT` ;
CREATE TABLE IF NOT EXISTS `DBM449Lab6`.`PRODUCT` (
`PROD_CODE` VARCHAR(10) NOT NULL,
`PROD_DESCRIPT` VARCHAR(35) NULL DEFAULT NULL,
`PROD_CATEGORY` VARCHAR(5) NULL DEFAULT NULL,
`SUP_CODE` INT(11) NOT NULL,
PRIMARY KEY (`PROD_CODE`),
CONSTRAINT `fk_PRODUCT_SUPPLIER`
FOREIGN KEY (`SUP_CODE`)
REFERENCES `DBM449Lab6`.`SUPPLIER` (`SUP_CODE`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
CREATE INDEX `fk_PRODUCT_SUPPLIER_idx` ON `DBM449Lab6`.`PRODUCT` (`SUP_CODE` ASC);
— —————————————————–
— Table `DBM449Lab6`.`SALES`
— —————————————————–
DROP TABLE IF EXISTS `DBM449Lab6`.`SALES` ;
CREATE TABLE IF NOT EXISTS `DBM449Lab6`.`SALES` (
`TIME_ID` DECIMAL(10,0) NOT NULL DEFAULT ‘0’,
`CUST_CODE` DECIMAL(10,0) NOT NULL DEFAULT ‘0’,
`PROD_CODE` VARCHAR(10) NOT NULL DEFAULT ”,
`SALE_UNITS` DECIMAL(10,0) NULL DEFAULT NULL,
`SALE_PRICE` DECIMAL(10,2) NULL DEFAULT NULL,
PRIMARY KEY (`TIME_ID`, `CUST_CODE`, `PROD_CODE`))
ENGINE = InnoDB;
— —————————————————–
— Table `DBM449Lab6`.`TIME`
— —————————————————–
DROP TABLE IF EXISTS `DBM449Lab6`.`TIME` ;
CREATE TABLE IF NOT EXISTS `DBM449Lab6`.`TIME` (
`TIME_ID` INT(11) NOT NULL,
`TIME_YEAR` INT(11) NULL DEFAULT NULL,
`TIME_MONTH` INT(11) NULL DEFAULT NULL,
`TIME_DAY` INT(11) NULL DEFAULT NULL,
`TIME_QTR` INT(11) NULL DEFAULT NULL,
PRIMARY KEY (`TIME_ID`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
INSERT INTO SUPPLIER VALUES(31225,’Bryson, Inc.’ ,’615′,’TN’);
INSERT INTO SUPPLIER VALUES(31226,’SuperLoo, Inc.’ ,’904′,’FL’);
INSERT INTO SUPPLIER VALUES(31231,’DE Supply’ ,’615′,’TN’);
INSERT INTO SUPPLIER VALUES(31344,’Gomez Bros.’ ,’615′,’KY’);
INSERT INTO SUPPLIER VALUES(32567,’Dome Supply’ ,’901′,’GA’);
INSERT INTO SUPPLIER VALUES(33119,’Randsets Ltd.’ ,’901′,’GA’);
INSERT INTO SUPPLIER VALUES(44004,’Brackman Bros.’ ,’615′,’TN’);
INSERT INTO SUPPLIER VALUES(44288,’ORDVA, Inc.’ ,’615′,’TN’);
INSERT INTO SUPPLIER VALUES(55443,’BK, Inc.’ ,’904′,’FL’);
INSERT INTO SUPPLIER VALUES(55501,’Damal Supplies’ ,’615′,’TN’);
INSERT INTO SUPPLIER VALUES(55595,’Rubicon Systems’ ,’904′,’FL’);
INSERT INTO PRODUCT VALUES(’11QER/31′,’Power painter, 15 psi., 3-nozzle’ ,’CAT1′,55595);
INSERT INTO PRODUCT VALUES(’13-Q2/P2′,’7.25-in. pwr. saw blade’ ,’CAT1′,31344);
INSERT INTO PRODUCT VALUES(’14-Q1/L3′,’9.00-in. pwr. saw blade’ ,’CAT1′,31344);
INSERT INTO PRODUCT VALUES(‘1546-QQ2′,’Hrd. cloth, 1/4-in., 2×50′ ,’CAT2’,33119);
INSERT INTO PRODUCT VALUES(‘1558-QW1′,’Hrd. cloth, 1/2-in., 3×50′ ,’CAT2’,33119);
INSERT INTO PRODUCT VALUES(‘2232/QTY’,’BD jigsaw, 12-in. blade’ ,’CAT2′,44288);
INSERT INTO PRODUCT VALUES(‘2232/QWE’,’BD jigsaw, 8-in. blade’ ,’CAT3′,44288);
INSERT INTO PRODUCT VALUES(‘2238/QPD’,’BD cordless drill, 1/2-in.’ ,’CAT3′,55595);
INSERT INTO PRODUCT VALUES(‘23109-HB’,’Claw hammer’ ,’CAT4′,31225);
INSERT INTO PRODUCT VALUES(‘23114-AA’,’Sledge hammer, 12 lb.’ ,’CAT4′,31225);
INSERT INTO PRODUCT VALUES(‘54778-2T’,’Rat-tail file, 1/8-in. fine’ ,’CAT1′,31344);
INSERT INTO PRODUCT VALUES(’89-WRE-Q’,’Hicut chain saw, 16 in.’ ,’CAT2′,44288);
INSERT INTO PRODUCT VALUES(‘PVC23DRT’,’PVC pipe, 3.5-in., 8-ft’ ,’CAT3′,31225);
INSERT INTO PRODUCT VALUES(‘SM-18277′,’1.25-in. metal screw, 25′ ,’CAT4’,31225);
INSERT INTO PRODUCT VALUES(‘SW-23116′,’2.5-in. wd. screw, 50′ ,’CAT2’,31231);
INSERT INTO PRODUCT VALUES(‘WR3/TT3′ ,’Steel matting, 4”x8”x1/6″, .5″ mesh’,’CAT3′,55595);
INSERT INTO DISTRICT VALUES(1,’NE’);
INSERT INTO DISTRICT VALUES(2,’NW’);
INSERT INTO DISTRICT VALUES(3,’SE’);
INSERT INTO DISTRICT VALUES(4,’SW’);
INSERT INTO CUSTOMER VALUES(110010,’Ramas’ ,’Alfred’,’A’ ,’TN’,3);
INSERT INTO CUSTOMER VALUES(110011,’Dunne’ ,’Leona’ ,’K’ ,’GA’,3);
INSERT INTO CUSTOMER VALUES(110012,’Smith’ ,’Kathy’ ,’W’ ,’NY’,1);
INSERT INTO CUSTOMER VALUES(110013,’Olowski’ ,’Paul’ ,’F’ ,’NJ’,1);
INSERT INTO CUSTOMER VALUES(110014,’Orlando’ ,’Myron’ ,NULL,’CO’,2);
INSERT INTO CUSTOMER VALUES(110015,’O”Brian’,’Amy’ ,’B’ ,’TN’,3);
INSERT INTO CUSTOMER VALUES(110016,’Brown’ ,’James’ ,’G’ ,’GA’,3);
INSERT INTO CUSTOMER VALUES(110017,’Williams’,’George’,NULL,’CA’,4);
INSERT INTO CUSTOMER VALUES(110018,’Farriss’ ,’Anne’ ,’G’ ,’CA’,4);
INSERT INTO CUSTOMER VALUES(110019,’Smith’ ,’Olette’,’K’ ,’CO’,2);
INSERT INTO TIME VALUES(201,2009,09,29,3);
INSERT INTO TIME VALUES(202,2009,09,30,3);
INSERT INTO TIME VALUES(203,2009,09,31,3);
INSERT INTO TIME VALUES(206,2009,10,03,4);
INSERT INTO TIME VALUES(207,2009,10,04,4);
INSERT INTO SALES VALUES(201,110014,’13-Q2/P2′,1,14.99);
INSERT INTO SALES VALUES(201,110014,’23109-HB’,1,11.95);
INSERT INTO SALES VALUES(201,110015,’54778-2T’,2,5.99);
INSERT INTO SALES VALUES(201,110015,’2238/QPD’,1,38.95);
INSERT INTO SALES VALUES(202,110016,’1546-QQ2′,1,311.95);
INSERT INTO SALES VALUES(202,110016,’13-Q2/P2′,5,15.99);
INSERT INTO SALES VALUES(202,110017,’54778-2T’,3,5.99);
INSERT INTO SALES VALUES(202,110017,’23109-HB’,2,11.95);
INSERT INTO SALES VALUES(202,110018,’PVC23DRT’,12,5.87);
INSERT INTO SALES VALUES(203,110012,’SM-18277′,3,8.95);
INSERT INTO SALES VALUES(203,110014,’2232/QTY’,1,109.92);
INSERT INTO SALES VALUES(203,110015,’23109-HB’,1,11.95);
INSERT INTO SALES VALUES(203,110015,’89-WRE-Q’,1,258.95);
INSERT INTO SALES VALUES(203,110016,’13-Q2/P2′,2,15.99);
INSERT INTO SALES VALUES(203,110016,’54778-2T’,1,5.99);
INSERT INTO SALES VALUES(203,110016,’PVC23DRT’,5,5.87);
INSERT INTO SALES VALUES(203,110017,’WR3/TT3′,3,111.95);
INSERT INTO SALES VALUES(203,110017,’23109-HB’,1,11.95);
INSERT INTO SALES VALUES(203,110017,’13-Q2/P2′,1,15.99);
INSERT INTO SALES VALUES(203,110018,’23109-HB’,1,11.95);
INSERT INTO SALES VALUES(203,110018,’54778-2T’,2,5.99);
INSERT INTO SALES VALUES(203,110018,’2238/QPD’,1,38.95);
INSERT INTO SALES VALUES(203,110019,’1546-QQ2′,1,311.95);
INSERT INTO SALES VALUES(206,110010,’13-Q2/P2′,5,15.99);
INSERT INTO SALES VALUES(206,110010,’54778-2T’,3,5.99);
INSERT INTO SALES VALUES(206,110010,’23109-HB’,2,11.95);
INSERT INTO SALES VALUES(206,110010,’PVC23DRT’,12,5.87);
INSERT INTO SALES VALUES(206,110011,’SM-18277′,3,8.95);
INSERT INTO SALES VALUES(206,110011,’2232/QTY’,1,109.92);
INSERT INTO SALES VALUES(206,110012,’23109-HB’,1,11.95);
INSERT INTO SALES VALUES(206,110012,’89-WRE-Q’,1,258.95);
INSERT INTO SALES VALUES(207,110013,’13-Q2/P2′,2,15.99);
INSERT INTO SALES VALUES(207,110013,’54778-2T’,1,5.99);
INSERT INTO SALES VALUES(207,110013,’PVC23DRT’,5,5.87);
INSERT INTO SALES VALUES(207,110014,’WR3/TT3′,3,111.95);
INSERT INTO SALES VALUES(207,110015,’23109-HB’,1,11.95);
Once the script has finished running, then issue a SHOW TABLES; sql statement. Make sure that you see the following tables listed.
STEP 2: Using the ROLLUP Extension
In this section of the lab you are going to create a sales report that will show a supplier code, product code and the total sales for each product based on unit price times a quantity. More importantly the column that shows the total sales will also show a grand total for the supplier as well as a grand total over all (this will be the last row of data shown). To do this you will use the ROLLUP extension as part of the GROUP BY clause in the query. Use aliases for the column names so that the output columns in the result set look like the following.
SUPPLIER CODE
PRODUCT
TOTAL SALES
31225
23109-HB
119.50
31225
PVC23DRT
199.58
31225
SM-18277
53.70
31225
372.78
31344
13-Q2/P2
254.84
31344
54778-2T
71.88
31344
326.72
33119
1546-QQ2
623.90
33119
623.90
44288
2232/QTY
219.84
44288
89-WRE-Q
517.90
44288
737.74
55595
2238/QPD
77.90
55595
WR3/TT3
671.70
55595
749.60
2810.74
Be sure to copy your SQL code and the result set produced and paste it into the appropriate place in the LAB6_REPORT.
STEP 3: Using the CUBE Extension
In this section of the lab you are going to examine the creation of a sales report that will show a month code, product code and the total sales for each product based on unit price times a quantity. At the time of this writing, MySQL does not implement the CUBE clause, so we will study an example constructed using the ORACLE DBMS. In this report, the column that shows the total sales will also show a subtotal for each month (in this case representing a quarter). Following the monthly totals for each product and the subtotal by month then the report will list a total for each product sold during the period with a grand total for all sales during the period (this will be the last row of data shown). To do this, the CUBE extension is used as part of the GROUP BY clause in the query. Aliases are used for the column names so that the output columns in the result set look like the following.
MONTH PRODUCT TOTAL SALES
———- ———- ———–
9 13-Q2/P2 142.91
9 1546-QQ2 623.9
9 2232/QTY 109.92
9 2238/QPD 77.9
9 23109-HB 71.7
9 54778-2T 47.92
9 89-WRE-Q 258.95
9 PVC23DRT 99.79
9 SM-18277 26.85
9 WR3/TT3 335.85
9 1795.69
MONTH PRODUCT TOTAL SALES
———- ———- ———–
10 13-Q2/P2 111.93
10 2232/QTY 109.92
10 23109-HB 47.8
10 54778-2T 23.96
10 89-WRE-Q 258.95
10 PVC23DRT 99.79
10 SM-18277 26.85
10 WR3/TT3 335.85
10 1015.05
13-Q2/P2 254.84
1546-QQ2 623.9
MONTH PRODUCT TOTAL SALES
———- ———- ———–
2232/QTY 219.84
2238/QPD 77.9
23109-HB 119.5
54778-2T 71.88
89-WRE-Q 517.9
PVC23DRT 199.58
SM-18277 53.7
WR3/TT3 671.7
2810.74
31 rows selected.
Here is the ORACLE PL/SQL query which generated these results. Please study the example carefully.
SQL> SELECT T.TIME_MONTH AS “MONTH”, P.PROD_COD
2 SUM(S.SALE_UNITS*S.SALE_PRICE) AS “TOTAL S
3 FROM SALES S, PRODUCT P, TIME T
4 WHERE S.TIME_ID = T.TIME_ID
5 AND S.PROD_CODE = P.PROD_CODE
6 GROUP BY CUBE (T.TIME_MONTH, P.PROD_CODE)
7 ORDER BY T.TIME_MONTH, P.PROD_CODE;
NOTE: This query will produce the same results using NATURAL JOIN.
SELECT TIME_MONTH AS “MONTH”, PROD_CODE AS “PRODUCT”, SUM(SALE_UNITS*SALE_PRICE) AS “TOTAL SALES”
FROM TIME NATURAL JOIN SALES NATURAL JOIN PRODUCT
GROUP BY CUBE (TIME_MONTH, PROD_CODE)
ORDER BY TIME_MONTH, PROD_CODE;
Notice that this report uses the SALES, PRODUCT and TIME tables. It is also possible to write the query using NATURAL JOIN but some developers may feel more comfortable using a traditional JOIN method that will work just as well. Notice that the grand total amount of 2810.74 is the same total as in step 2.
CHECKPOINT QUESTION: Research Data Warehouse Solutions that may be integrated into MySQL enterprise architecture (e.g., PENTAHO). Explain how these solutions may be employed to overcome the current limitations in MySQL support for OLAP functionality. Pay special attention to the reporting and analytic capabilities of these solutions. Based on your analysis and research, do you believe that analytic functions such as GROUP BY CUBE are best implemented in the database (MySQL), the Data Warehouse and Reporting Engine (e.g., PENTAHO), or both. Fully explain your analysis and conclusions.
STEP 4: Materialized Views and a Refresh Procedure
Materialized views (MVs), sometimes referred to as snapshots are a very important aspect of dealing with data when doing data mining or working with a data warehouse. Unlike regular views, a materialized view does not always automatically react to changes made in the base tables of the view. In database systems that directly implement MVs, a Materialized View Log must be created on each base table that will be used in the view. As discussed and explored briefly at the conclusion of Lab 5, MySQL does not directly implement materialized views, but these may be effectively emulated using tables constructed with the same attributes as the view, provided that steps are taken to ensure the automatic update or refresh of the table. For instructional purposes, we will accomplish this by the simple expedient of creating a stored procedure which will drop, recreate, and rebuild the table serving as the view. In our exploration of the concept of the materialized view, we are going to create we are going to use the TIME and the SALES tables.
Because we will emulate an MV in our solution, we will craft a stored procedure to update the MV.
Create and install a stored procedure, named REFRESH_MV_SALESBYMONTH, using the following SQL SELECT statement to guide you. This SELECT statement demonstrates the data to be selected to populate the table. Your stored procedure must: (1) drop the table if it exists; and (2) SELECT INTO the table MV_SALESBYMONTH to create and populate it. Note that, with this logic, no separate logic is needed to first create the view—simply run the stored procedure. The details of the implementation are left to you.
SELECT TIME_YEAR AS “YEAR”, TIME_MONTH AS “MONTH”, PROD_CODE AS “PRODUCT”,
SUM(SALE_UNITS) AS “UNITS SOLD”, SUM(SALE_UNITS*SALE_PRICE) AS “SALES TOTAL”
FROM TIME T, SALES S
WHERE S.TIME_ID = T.TIME_ID
GROUP BY TIME_YEAR, TIME_MONTH, PROD_CODE;
Be sure to copy your SQL code and the result set produced and paste it into the appropriate place in the LAB6_REPORT.
STEP 5: Using the Materialized View
First, CALL REFRESH_MV_SALESBYMONTH. This will make sure that the view is created, and currently up-to-date.
Run the SQL statement: SELECT * FROM MV_SALESBYMONTH. The output columns from your view should look similar to the following (use aliases to format the column headings) and you should have 18 rows in the result set.
YEAR MONTH PRODUCT CO UNITS SOLD SALES TOTAL
Now we are going to add some data and update the view. Remember, we must manually run the stored procedure to update the view, as it will not (yet!) automatically itself.
To begin with, insert the following data into the SALES table—(207, 110016, ‘SM-18277’,1,8.95).
CALL the stored procedure to refresh the view.
Query the view once again.
You should now see that the row for units sold in month 10 for SM-18277 has increased from 3 to 4 and total sales amount has gone from 26.85 to 35.80.
Delete the row you just added to the SALES table, and call the stored procedure to refresh the view, proving that things are up-to-date.
Create a Trigger on the SALES table so that any insert automatically fires off the stored procedure to update the view.
Test your trigger, by again inserting the following data into the SALES table—(207, 110016, ‘SM-18277’,1,8.95).
Query the view once again.
You should now see that the row for units sold in month 10 for SM-18277 has increased from 3 to 4 and total sales amount has gone from 26.85 to 35.80.
CHECKPOINT QUESTION: For instructional purposes and simplicity, we have indulged in the expedient of dropping and recreating the entire MV_SALESBYMONTH table, which now occurs each time a new record is inserted on the SALES table. Would this be unacceptable in practice? Explain why or why not. What other events, and what other tables would require wire-up of triggers in order to ensure that the view is kept up-to-date at all times?
Be sure to copy your SQL code and the result set produced and paste it into the appropriate place in the LAB6_REPORT.
Laboratory Report DeVry University College of Engineering and Information Sciences
Course Number: DBM449
Laboratory Number: 3
Laboratory Title: SWL Analytical Extensions & Materialized Views
Note: There is no limit on how much information you will enter under the three topics below. It is important to be clear and complete with your comments. Like a scientist you are documenting your progress in this week’s lab experiment.
Objectives: (In your own words what was this lab designed to accomplish? What was its purpose?)
Results: (Discuss the steps you used to complete your lab. Were you successful? What did you learn? What were the results? Explain what you did to accomplish each step. You can include screen shots, code listings, and so on. to clearly explain what you did. Be sure to record all results specifically directed by the lab procedure. Number all results to reflect the procedure number to which they correspond.)
Conclusions: (After completing this lab, in your own words, what conclusions can you draw from this experience?)
0 notes
Text
DBM 449 Laboratory Procedures iLab 6 Answers
Follow Below Link to Download Tutorial
https://homeworklance.com/downloads/dbm-449-laboratory-procedures-ilab-6-answers/
For More Information Visit Our Website ( https://homeworklance.com/ )
Email us At: [email protected] or [email protected]
I. OBJECTIVES
Understand and become familiar with the SQL Analytical Extensions.
Learn to create, use, and maintain materialized views, and their functional equivalents.
Effectively apply Advanced Aggregate SQL Operations, such as GROUP BY ROLLUP to solve business intelligence questions and analytical processing problems.
II. PARTS LIST
EDUPE-VT Omnymbus Virtual Machine Environment (https://devry.edupe.net:9090/) and/or:
MySQL (dev.mysql.com/downloads)
III. PROCEDURE
Scenario and Summary
For the lab this week, we are going to look at how the ROLLUP and CUBE extensions available in SQL can be used to create query result sets that have more than one dimension to them. Both of these extensions are used in conjunction with the GROUP BY clause and allow for a much broader look at the data.
To record your work for this lab use the lab report found at the end of this document. As in your previous labs, you will need to copy/paste your SQL statements and results into this document. Upon completion and prior to the due date, submit this document to the appropriate Dropbox.
iLAB STEPS
STEP 1: Setting Up
For this lab you will be using a different user and set of tables than you have used so far for other labs. To set up your instance you will need to do the following.
The first thing you will do for this lab is to run the following SQL Script. Begin by creating the DBM449Lab6 Schema, and creating any user accounts and privileges you wish to use (at least one).
Run the following script to create and populate a set of tables that will be used for this lab. Instructions for this are outlined in Step 1.
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=’TRADITIONAL,ALLOW_INVALID_DATES’;
USE `DBM449Lab6` ;
— —————————————————–
— Table `DBM449Lab6`.`DISTRICT`
— —————————————————–
DROP TABLE IF EXISTS `DBM449Lab6`.`DISTRICT` ;
CREATE TABLE IF NOT EXISTS `DBM449Lab6`.`DISTRICT` (
`DIST_ID` INT(11) NOT NULL,
`DIST_NAME` VARCHAR(10) NULL DEFAULT NULL,
PRIMARY KEY (`DIST_ID`))
ENGINE = InnoDB;
— —————————————————–
— Table `DBM449Lab6`.`CUSTOMER`
— —————————————————–
DROP TABLE IF EXISTS `DBM449Lab6`.`CUSTOMER` ;
CREATE TABLE IF NOT EXISTS `DBM449Lab6`.`CUSTOMER` (
`CUST_CODE` DECIMAL(10,0) NOT NULL,
`CUST_LNAME` VARCHAR(15) NULL DEFAULT NULL,
`CUST_FNAME` VARCHAR(15) NULL DEFAULT NULL,
`CUST_INITIAL` CHAR(1) NULL DEFAULT NULL,
`CUST_STATE` CHAR(2) NULL DEFAULT NULL,
`DIST_ID` INT(11) NOT NULL,
PRIMARY KEY (`CUST_CODE`),
CONSTRAINT `fk_CUSTOMER_DISTRICT1`
FOREIGN KEY (`DIST_ID`)
REFERENCES `DBM449Lab6`.`DISTRICT` (`DIST_ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
CREATE INDEX `fk_CUSTOMER_DISTRICT1_idx` ON `DBM449Lab6`.`CUSTOMER` (`DIST_ID` ASC);
— —————————————————–
— Table `DBM449Lab6`.`SUPPLIER`
— —————————————————–
DROP TABLE IF EXISTS `DBM449Lab6`.`SUPPLIER` ;
CREATE TABLE IF NOT EXISTS `DBM449Lab6`.`SUPPLIER` (
`SUP_CODE` INT(11) NOT NULL,
`SUP_NAME` VARCHAR(35) NULL DEFAULT NULL,
`SUP_AREACODE` CHAR(3) NULL DEFAULT NULL,
`SUP_STATE` CHAR(2) NULL DEFAULT NULL,
PRIMARY KEY (`SUP_CODE`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
— —————————————————–
— Table `DBM449Lab6`.`PRODUCT`
— —————————————————–
DROP TABLE IF EXISTS `DBM449Lab6`.`PRODUCT` ;
CREATE TABLE IF NOT EXISTS `DBM449Lab6`.`PRODUCT` (
`PROD_CODE` VARCHAR(10) NOT NULL,
`PROD_DESCRIPT` VARCHAR(35) NULL DEFAULT NULL,
`PROD_CATEGORY` VARCHAR(5) NULL DEFAULT NULL,
`SUP_CODE` INT(11) NOT NULL,
PRIMARY KEY (`PROD_CODE`),
CONSTRAINT `fk_PRODUCT_SUPPLIER`
FOREIGN KEY (`SUP_CODE`)
REFERENCES `DBM449Lab6`.`SUPPLIER` (`SUP_CODE`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
CREATE INDEX `fk_PRODUCT_SUPPLIER_idx` ON `DBM449Lab6`.`PRODUCT` (`SUP_CODE` ASC);
— —————————————————–
— Table `DBM449Lab6`.`SALES`
— —————————————————–
DROP TABLE IF EXISTS `DBM449Lab6`.`SALES` ;
CREATE TABLE IF NOT EXISTS `DBM449Lab6`.`SALES` (
`TIME_ID` DECIMAL(10,0) NOT NULL DEFAULT ‘0’,
`CUST_CODE` DECIMAL(10,0) NOT NULL DEFAULT ‘0’,
`PROD_CODE` VARCHAR(10) NOT NULL DEFAULT ”,
`SALE_UNITS` DECIMAL(10,0) NULL DEFAULT NULL,
`SALE_PRICE` DECIMAL(10,2) NULL DEFAULT NULL,
PRIMARY KEY (`TIME_ID`, `CUST_CODE`, `PROD_CODE`))
ENGINE = InnoDB;
— —————————————————–
— Table `DBM449Lab6`.`TIME`
— —————————————————–
DROP TABLE IF EXISTS `DBM449Lab6`.`TIME` ;
CREATE TABLE IF NOT EXISTS `DBM449Lab6`.`TIME` (
`TIME_ID` INT(11) NOT NULL,
`TIME_YEAR` INT(11) NULL DEFAULT NULL,
`TIME_MONTH` INT(11) NULL DEFAULT NULL,
`TIME_DAY` INT(11) NULL DEFAULT NULL,
`TIME_QTR` INT(11) NULL DEFAULT NULL,
PRIMARY KEY (`TIME_ID`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
INSERT INTO SUPPLIER VALUES(31225,’Bryson, Inc.’ ,’615′,’TN’);
INSERT INTO SUPPLIER VALUES(31226,’SuperLoo, Inc.’ ,’904′,’FL’);
INSERT INTO SUPPLIER VALUES(31231,’DE Supply’ ,’615′,’TN’);
INSERT INTO SUPPLIER VALUES(31344,’Gomez Bros.’ ,’615′,’KY’);
INSERT INTO SUPPLIER VALUES(32567,’Dome Supply’ ,’901′,’GA’);
INSERT INTO SUPPLIER VALUES(33119,’Randsets Ltd.’ ,’901′,’GA’);
INSERT INTO SUPPLIER VALUES(44004,’Brackman Bros.’ ,’615′,’TN’);
INSERT INTO SUPPLIER VALUES(44288,’ORDVA, Inc.’ ,’615′,’TN’);
INSERT INTO SUPPLIER VALUES(55443,’BK, Inc.’ ,’904′,’FL’);
INSERT INTO SUPPLIER VALUES(55501,’Damal Supplies’ ,’615′,’TN’);
INSERT INTO SUPPLIER VALUES(55595,’Rubicon Systems’ ,’904′,’FL’);
INSERT INTO PRODUCT VALUES(’11QER/31′,’Power painter, 15 psi., 3-nozzle’ ,’CAT1′,55595);
INSERT INTO PRODUCT VALUES(’13-Q2/P2′,’7.25-in. pwr. saw blade’ ,’CAT1′,31344);
INSERT INTO PRODUCT VALUES(’14-Q1/L3′,’9.00-in. pwr. saw blade’ ,’CAT1′,31344);
INSERT INTO PRODUCT VALUES(‘1546-QQ2′,’Hrd. cloth, 1/4-in., 2×50′ ,’CAT2’,33119);
INSERT INTO PRODUCT VALUES(‘1558-QW1′,’Hrd. cloth, 1/2-in., 3×50′ ,’CAT2’,33119);
INSERT INTO PRODUCT VALUES(‘2232/QTY’,’BD jigsaw, 12-in. blade’ ,’CAT2′,44288);
INSERT INTO PRODUCT VALUES(‘2232/QWE’,’BD jigsaw, 8-in. blade’ ,’CAT3′,44288);
INSERT INTO PRODUCT VALUES(‘2238/QPD’,’BD cordless drill, 1/2-in.’ ,’CAT3′,55595);
INSERT INTO PRODUCT VALUES(‘23109-HB’,’Claw hammer’ ,’CAT4′,31225);
INSERT INTO PRODUCT VALUES(‘23114-AA’,’Sledge hammer, 12 lb.’ ,’CAT4′,31225);
INSERT INTO PRODUCT VALUES(‘54778-2T’,’Rat-tail file, 1/8-in. fine’ ,’CAT1′,31344);
INSERT INTO PRODUCT VALUES(’89-WRE-Q’,’Hicut chain saw, 16 in.’ ,’CAT2′,44288);
INSERT INTO PRODUCT VALUES(‘PVC23DRT’,’PVC pipe, 3.5-in., 8-ft’ ,’CAT3′,31225);
INSERT INTO PRODUCT VALUES(‘SM-18277′,’1.25-in. metal screw, 25′ ,’CAT4’,31225);
INSERT INTO PRODUCT VALUES(‘SW-23116′,’2.5-in. wd. screw, 50′ ,’CAT2’,31231);
INSERT INTO PRODUCT VALUES(‘WR3/TT3′ ,’Steel matting, 4”x8”x1/6″, .5″ mesh’,’CAT3′,55595);
INSERT INTO DISTRICT VALUES(1,’NE’);
INSERT INTO DISTRICT VALUES(2,’NW’);
INSERT INTO DISTRICT VALUES(3,’SE’);
INSERT INTO DISTRICT VALUES(4,’SW’);
INSERT INTO CUSTOMER VALUES(110010,’Ramas’ ,’Alfred’,’A’ ,’TN’,3);
INSERT INTO CUSTOMER VALUES(110011,’Dunne’ ,’Leona’ ,’K’ ,’GA’,3);
INSERT INTO CUSTOMER VALUES(110012,’Smith’ ,’Kathy’ ,’W’ ,’NY’,1);
INSERT INTO CUSTOMER VALUES(110013,’Olowski’ ,’Paul’ ,’F’ ,’NJ’,1);
INSERT INTO CUSTOMER VALUES(110014,’Orlando’ ,’Myron’ ,NULL,’CO’,2);
INSERT INTO CUSTOMER VALUES(110015,’O”Brian’,’Amy’ ,’B’ ,’TN’,3);
INSERT INTO CUSTOMER VALUES(110016,’Brown’ ,’James’ ,’G’ ,’GA’,3);
INSERT INTO CUSTOMER VALUES(110017,’Williams’,’George’,NULL,’CA’,4);
INSERT INTO CUSTOMER VALUES(110018,’Farriss’ ,’Anne’ ,’G’ ,’CA’,4);
INSERT INTO CUSTOMER VALUES(110019,’Smith’ ,’Olette’,’K’ ,’CO’,2);
INSERT INTO TIME VALUES(201,2009,09,29,3);
INSERT INTO TIME VALUES(202,2009,09,30,3);
INSERT INTO TIME VALUES(203,2009,09,31,3);
INSERT INTO TIME VALUES(206,2009,10,03,4);
INSERT INTO TIME VALUES(207,2009,10,04,4);
INSERT INTO SALES VALUES(201,110014,’13-Q2/P2′,1,14.99);
INSERT INTO SALES VALUES(201,110014,’23109-HB’,1,11.95);
INSERT INTO SALES VALUES(201,110015,’54778-2T’,2,5.99);
INSERT INTO SALES VALUES(201,110015,’2238/QPD’,1,38.95);
INSERT INTO SALES VALUES(202,110016,’1546-QQ2′,1,311.95);
INSERT INTO SALES VALUES(202,110016,’13-Q2/P2′,5,15.99);
INSERT INTO SALES VALUES(202,110017,’54778-2T’,3,5.99);
INSERT INTO SALES VALUES(202,110017,’23109-HB’,2,11.95);
INSERT INTO SALES VALUES(202,110018,’PVC23DRT’,12,5.87);
INSERT INTO SALES VALUES(203,110012,’SM-18277′,3,8.95);
INSERT INTO SALES VALUES(203,110014,’2232/QTY’,1,109.92);
INSERT INTO SALES VALUES(203,110015,’23109-HB’,1,11.95);
INSERT INTO SALES VALUES(203,110015,’89-WRE-Q’,1,258.95);
INSERT INTO SALES VALUES(203,110016,’13-Q2/P2′,2,15.99);
INSERT INTO SALES VALUES(203,110016,’54778-2T’,1,5.99);
INSERT INTO SALES VALUES(203,110016,’PVC23DRT’,5,5.87);
INSERT INTO SALES VALUES(203,110017,’WR3/TT3′,3,111.95);
INSERT INTO SALES VALUES(203,110017,’23109-HB’,1,11.95);
INSERT INTO SALES VALUES(203,110017,’13-Q2/P2′,1,15.99);
INSERT INTO SALES VALUES(203,110018,’23109-HB’,1,11.95);
INSERT INTO SALES VALUES(203,110018,’54778-2T’,2,5.99);
INSERT INTO SALES VALUES(203,110018,’2238/QPD’,1,38.95);
INSERT INTO SALES VALUES(203,110019,’1546-QQ2′,1,311.95);
INSERT INTO SALES VALUES(206,110010,’13-Q2/P2′,5,15.99);
INSERT INTO SALES VALUES(206,110010,’54778-2T’,3,5.99);
INSERT INTO SALES VALUES(206,110010,’23109-HB’,2,11.95);
INSERT INTO SALES VALUES(206,110010,’PVC23DRT’,12,5.87);
INSERT INTO SALES VALUES(206,110011,’SM-18277′,3,8.95);
INSERT INTO SALES VALUES(206,110011,’2232/QTY’,1,109.92);
INSERT INTO SALES VALUES(206,110012,’23109-HB’,1,11.95);
INSERT INTO SALES VALUES(206,110012,’89-WRE-Q’,1,258.95);
INSERT INTO SALES VALUES(207,110013,’13-Q2/P2′,2,15.99);
INSERT INTO SALES VALUES(207,110013,’54778-2T’,1,5.99);
INSERT INTO SALES VALUES(207,110013,’PVC23DRT’,5,5.87);
INSERT INTO SALES VALUES(207,110014,’WR3/TT3′,3,111.95);
INSERT INTO SALES VALUES(207,110015,’23109-HB’,1,11.95);
Once the script has finished running, then issue a SHOW TABLES; sql statement. Make sure that you see the following tables listed.
STEP 2: Using the ROLLUP Extension
In this section of the lab you are going to create a sales report that will show a supplier code, product code and the total sales for each product based on unit price times a quantity. More importantly the column that shows the total sales will also show a grand total for the supplier as well as a grand total over all (this will be the last row of data shown). To do this you will use the ROLLUP extension as part of the GROUP BY clause in the query. Use aliases for the column names so that the output columns in the result set look like the following.
SUPPLIER CODE
PRODUCT
TOTAL SALES
31225
23109-HB
119.50
31225
PVC23DRT
199.58
31225
SM-18277
53.70
31225
372.78
31344
13-Q2/P2
254.84
31344
54778-2T
71.88
31344
326.72
33119
1546-QQ2
623.90
33119
623.90
44288
2232/QTY
219.84
44288
89-WRE-Q
517.90
44288
737.74
55595
2238/QPD
77.90
55595
WR3/TT3
671.70
55595
749.60
2810.74
Be sure to copy your SQL code and the result set produced and paste it into the appropriate place in the LAB6_REPORT.
STEP 3: Using the CUBE Extension
In this section of the lab you are going to examine the creation of a sales report that will show a month code, product code and the total sales for each product based on unit price times a quantity. At the time of this writing, MySQL does not implement the CUBE clause, so we will study an example constructed using the ORACLE DBMS. In this report, the column that shows the total sales will also show a subtotal for each month (in this case representing a quarter). Following the monthly totals for each product and the subtotal by month then the report will list a total for each product sold during the period with a grand total for all sales during the period (this will be the last row of data shown). To do this, the CUBE extension is used as part of the GROUP BY clause in the query. Aliases are used for the column names so that the output columns in the result set look like the following.
MONTH PRODUCT TOTAL SALES
———- ———- ———–
9 13-Q2/P2 142.91
9 1546-QQ2 623.9
9 2232/QTY 109.92
9 2238/QPD 77.9
9 23109-HB 71.7
9 54778-2T 47.92
9 89-WRE-Q 258.95
9 PVC23DRT 99.79
9 SM-18277 26.85
9 WR3/TT3 335.85
9 1795.69
MONTH PRODUCT TOTAL SALES
———- ———- ———–
10 13-Q2/P2 111.93
10 2232/QTY 109.92
10 23109-HB 47.8
10 54778-2T 23.96
10 89-WRE-Q 258.95
10 PVC23DRT 99.79
10 SM-18277 26.85
10 WR3/TT3 335.85
10 1015.05
13-Q2/P2 254.84
1546-QQ2 623.9
MONTH PRODUCT TOTAL SALES
———- ———- ———–
2232/QTY 219.84
2238/QPD 77.9
23109-HB 119.5
54778-2T 71.88
89-WRE-Q 517.9
PVC23DRT 199.58
SM-18277 53.7
WR3/TT3 671.7
2810.74
31 rows selected.
Here is the ORACLE PL/SQL query which generated these results. Please study the example carefully.
SQL> SELECT T.TIME_MONTH AS “MONTH”, P.PROD_COD
2 SUM(S.SALE_UNITS*S.SALE_PRICE) AS “TOTAL S
3 FROM SALES S, PRODUCT P, TIME T
4 WHERE S.TIME_ID = T.TIME_ID
5 AND S.PROD_CODE = P.PROD_CODE
6 GROUP BY CUBE (T.TIME_MONTH, P.PROD_CODE)
7 ORDER BY T.TIME_MONTH, P.PROD_CODE;
NOTE: This query will produce the same results using NATURAL JOIN.
SELECT TIME_MONTH AS “MONTH”, PROD_CODE AS “PRODUCT”, SUM(SALE_UNITS*SALE_PRICE) AS “TOTAL SALES”
FROM TIME NATURAL JOIN SALES NATURAL JOIN PRODUCT
GROUP BY CUBE (TIME_MONTH, PROD_CODE)
ORDER BY TIME_MONTH, PROD_CODE;
Notice that this report uses the SALES, PRODUCT and TIME tables. It is also possible to write the query using NATURAL JOIN but some developers may feel more comfortable using a traditional JOIN method that will work just as well. Notice that the grand total amount of 2810.74 is the same total as in step 2.
CHECKPOINT QUESTION: Research Data Warehouse Solutions that may be integrated into MySQL enterprise architecture (e.g., PENTAHO). Explain how these solutions may be employed to overcome the current limitations in MySQL support for OLAP functionality. Pay special attention to the reporting and analytic capabilities of these solutions. Based on your analysis and research, do you believe that analytic functions such as GROUP BY CUBE are best implemented in the database (MySQL), the Data Warehouse and Reporting Engine (e.g., PENTAHO), or both. Fully explain your analysis and conclusions.
STEP 4: Materialized Views and a Refresh Procedure
Materialized views (MVs), sometimes referred to as snapshots are a very important aspect of dealing with data when doing data mining or working with a data warehouse. Unlike regular views, a materialized view does not always automatically react to changes made in the base tables of the view. In database systems that directly implement MVs, a Materialized View Log must be created on each base table that will be used in the view. As discussed and explored briefly at the conclusion of Lab 5, MySQL does not directly implement materialized views, but these may be effectively emulated using tables constructed with the same attributes as the view, provided that steps are taken to ensure the automatic update or refresh of the table. For instructional purposes, we will accomplish this by the simple expedient of creating a stored procedure which will drop, recreate, and rebuild the table serving as the view. In our exploration of the concept of the materialized view, we are going to create we are going to use the TIME and the SALES tables.
Because we will emulate an MV in our solution, we will craft a stored procedure to update the MV.
Create and install a stored procedure, named REFRESH_MV_SALESBYMONTH, using the following SQL SELECT statement to guide you. This SELECT statement demonstrates the data to be selected to populate the table. Your stored procedure must: (1) drop the table if it exists; and (2) SELECT INTO the table MV_SALESBYMONTH to create and populate it. Note that, with this logic, no separate logic is needed to first create the view—simply run the stored procedure. The details of the implementation are left to you.
SELECT TIME_YEAR AS “YEAR”, TIME_MONTH AS “MONTH”, PROD_CODE AS “PRODUCT”,
SUM(SALE_UNITS) AS “UNITS SOLD”, SUM(SALE_UNITS*SALE_PRICE) AS “SALES TOTAL”
FROM TIME T, SALES S
WHERE S.TIME_ID = T.TIME_ID
GROUP BY TIME_YEAR, TIME_MONTH, PROD_CODE;
Be sure to copy your SQL code and the result set produced and paste it into the appropriate place in the LAB6_REPORT.
STEP 5: Using the Materialized View
First, CALL REFRESH_MV_SALESBYMONTH. This will make sure that the view is created, and currently up-to-date.
Run the SQL statement: SELECT * FROM MV_SALESBYMONTH. The output columns from your view should look similar to the following (use aliases to format the column headings) and you should have 18 rows in the result set.
YEAR MONTH PRODUCT CO UNITS SOLD SALES TOTAL
Now we are going to add some data and update the view. Remember, we must manually run the stored procedure to update the view, as it will not (yet!) automatically itself.
To begin with, insert the following data into the SALES table—(207, 110016, ‘SM-18277’,1,8.95).
CALL the stored procedure to refresh the view.
Query the view once again.
You should now see that the row for units sold in month 10 for SM-18277 has increased from 3 to 4 and total sales amount has gone from 26.85 to 35.80.
Delete the row you just added to the SALES table, and call the stored procedure to refresh the view, proving that things are up-to-date.
Create a Trigger on the SALES table so that any insert automatically fires off the stored procedure to update the view.
Test your trigger, by again inserting the following data into the SALES table—(207, 110016, ‘SM-18277’,1,8.95).
Query the view once again.
You should now see that the row for units sold in month 10 for SM-18277 has increased from 3 to 4 and total sales amount has gone from 26.85 to 35.80.
CHECKPOINT QUESTION: For instructional purposes and simplicity, we have indulged in the expedient of dropping and recreating the entire MV_SALESBYMONTH table, which now occurs each time a new record is inserted on the SALES table. Would this be unacceptable in practice? Explain why or why not. What other events, and what other tables would require wire-up of triggers in order to ensure that the view is kept up-to-date at all times?
Be sure to copy your SQL code and the result set produced and paste it into the appropriate place in the LAB6_REPORT.
Laboratory Report DeVry University College of Engineering and Information Sciences
Course Number: DBM449
Laboratory Number: 3
Laboratory Title: SWL Analytical Extensions & Materialized Views
Note: There is no limit on how much information you will enter under the three topics below. It is important to be clear and complete with your comments. Like a scientist you are documenting your progress in this week’s lab experiment.
Objectives: (In your own words what was this lab designed to accomplish? What was its purpose?)
Results: (Discuss the steps you used to complete your lab. Were you successful? What did you learn? What were the results? Explain what you did to accomplish each step. You can include screen shots, code listings, and so on. to clearly explain what you did. Be sure to record all results specifically directed by the lab procedure. Number all results to reflect the procedure number to which they correspond.)
Conclusions: (After completing this lab, in your own words, what conclusions can you draw from this experience?)
0 notes
Text
DBM 449 Laboratory Procedures iLab 6 Answers Follow Below Link to Download Tutorial
https://homeworklance.com/downloads/dbm-449-laboratory-procedures-ilab-6-answers/
For More Information Visit Our Website ( https://homeworklance.com/ )
Email us At: [email protected] or [email protected]
I. OBJECTIVES
Understand and become familiar with the SQL Analytical Extensions.
Learn to create, use, and maintain materialized views, and their functional equivalents.
Effectively apply Advanced Aggregate SQL Operations, such as GROUP BY ROLLUP to solve business intelligence questions and analytical processing problems.
II. PARTS LIST
EDUPE-VT Omnymbus Virtual Machine Environment (https://devry.edupe.net:9090/) and/or:
MySQL (dev.mysql.com/downloads)
III. PROCEDURE
Scenario and Summary
For the lab this week, we are going to look at how the ROLLUP and CUBE extensions available in SQL can be used to create query result sets that have more than one dimension to them. Both of these extensions are used in conjunction with the GROUP BY clause and allow for a much broader look at the data.
To record your work for this lab use the lab report found at the end of this document. As in your previous labs, you will need to copy/paste your SQL statements and results into this document. Upon completion and prior to the due date, submit this document to the appropriate Dropbox.
iLAB STEPS
STEP 1: Setting Up
For this lab you will be using a different user and set of tables than you have used so far for other labs. To set up your instance you will need to do the following.
The first thing you will do for this lab is to run the following SQL Script. Begin by creating the DBM449Lab6 Schema, and creating any user accounts and privileges you wish to use (at least one).
Run the following script to create and populate a set of tables that will be used for this lab. Instructions for this are outlined in Step 1.
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=’TRADITIONAL,ALLOW_INVALID_DATES’;
USE `DBM449Lab6` ;
— —————————————————–
— Table `DBM449Lab6`.`DISTRICT`
— —————————————————–
DROP TABLE IF EXISTS `DBM449Lab6`.`DISTRICT` ;
CREATE TABLE IF NOT EXISTS `DBM449Lab6`.`DISTRICT` (
`DIST_ID` INT(11) NOT NULL,
`DIST_NAME` VARCHAR(10) NULL DEFAULT NULL,
PRIMARY KEY (`DIST_ID`))
ENGINE = InnoDB;
— —————————————————–
— Table `DBM449Lab6`.`CUSTOMER`
— —————————————————–
DROP TABLE IF EXISTS `DBM449Lab6`.`CUSTOMER` ;
CREATE TABLE IF NOT EXISTS `DBM449Lab6`.`CUSTOMER` (
`CUST_CODE` DECIMAL(10,0) NOT NULL,
`CUST_LNAME` VARCHAR(15) NULL DEFAULT NULL,
`CUST_FNAME` VARCHAR(15) NULL DEFAULT NULL,
`CUST_INITIAL` CHAR(1) NULL DEFAULT NULL,
`CUST_STATE` CHAR(2) NULL DEFAULT NULL,
`DIST_ID` INT(11) NOT NULL,
PRIMARY KEY (`CUST_CODE`),
CONSTRAINT `fk_CUSTOMER_DISTRICT1`
FOREIGN KEY (`DIST_ID`)
REFERENCES `DBM449Lab6`.`DISTRICT` (`DIST_ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
CREATE INDEX `fk_CUSTOMER_DISTRICT1_idx` ON `DBM449Lab6`.`CUSTOMER` (`DIST_ID` ASC);
— —————————————————–
— Table `DBM449Lab6`.`SUPPLIER`
— —————————————————–
DROP TABLE IF EXISTS `DBM449Lab6`.`SUPPLIER` ;
CREATE TABLE IF NOT EXISTS `DBM449Lab6`.`SUPPLIER` (
`SUP_CODE` INT(11) NOT NULL,
`SUP_NAME` VARCHAR(35) NULL DEFAULT NULL,
`SUP_AREACODE` CHAR(3) NULL DEFAULT NULL,
`SUP_STATE` CHAR(2) NULL DEFAULT NULL,
PRIMARY KEY (`SUP_CODE`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
— —————————————————–
— Table `DBM449Lab6`.`PRODUCT`
— —————————————————–
DROP TABLE IF EXISTS `DBM449Lab6`.`PRODUCT` ;
CREATE TABLE IF NOT EXISTS `DBM449Lab6`.`PRODUCT` (
`PROD_CODE` VARCHAR(10) NOT NULL,
`PROD_DESCRIPT` VARCHAR(35) NULL DEFAULT NULL,
`PROD_CATEGORY` VARCHAR(5) NULL DEFAULT NULL,
`SUP_CODE` INT(11) NOT NULL,
PRIMARY KEY (`PROD_CODE`),
CONSTRAINT `fk_PRODUCT_SUPPLIER`
FOREIGN KEY (`SUP_CODE`)
REFERENCES `DBM449Lab6`.`SUPPLIER` (`SUP_CODE`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
CREATE INDEX `fk_PRODUCT_SUPPLIER_idx` ON `DBM449Lab6`.`PRODUCT` (`SUP_CODE` ASC);
— —————————————————–
— Table `DBM449Lab6`.`SALES`
— —————————————————–
DROP TABLE IF EXISTS `DBM449Lab6`.`SALES` ;
CREATE TABLE IF NOT EXISTS `DBM449Lab6`.`SALES` (
`TIME_ID` DECIMAL(10,0) NOT NULL DEFAULT ‘0’,
`CUST_CODE` DECIMAL(10,0) NOT NULL DEFAULT ‘0’,
`PROD_CODE` VARCHAR(10) NOT NULL DEFAULT ”,
`SALE_UNITS` DECIMAL(10,0) NULL DEFAULT NULL,
`SALE_PRICE` DECIMAL(10,2) NULL DEFAULT NULL,
PRIMARY KEY (`TIME_ID`, `CUST_CODE`, `PROD_CODE`))
ENGINE = InnoDB;
— —————————————————–
— Table `DBM449Lab6`.`TIME`
— —————————————���———–
DROP TABLE IF EXISTS `DBM449Lab6`.`TIME` ;
CREATE TABLE IF NOT EXISTS `DBM449Lab6`.`TIME` (
`TIME_ID` INT(11) NOT NULL,
`TIME_YEAR` INT(11) NULL DEFAULT NULL,
`TIME_MONTH` INT(11) NULL DEFAULT NULL,
`TIME_DAY` INT(11) NULL DEFAULT NULL,
`TIME_QTR` INT(11) NULL DEFAULT NULL,
PRIMARY KEY (`TIME_ID`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
INSERT INTO SUPPLIER VALUES(31225,’Bryson, Inc.’ ,’615′,’TN’);
INSERT INTO SUPPLIER VALUES(31226,’SuperLoo, Inc.’ ,’904′,’FL’);
INSERT INTO SUPPLIER VALUES(31231,’DE Supply’ ,’615′,’TN’);
INSERT INTO SUPPLIER VALUES(31344,’Gomez Bros.’ ,’615′,’KY’);
INSERT INTO SUPPLIER VALUES(32567,’Dome Supply’ ,’901′,’GA’);
INSERT INTO SUPPLIER VALUES(33119,’Randsets Ltd.’ ,’901′,’GA’);
INSERT INTO SUPPLIER VALUES(44004,’Brackman Bros.’ ,’615′,’TN’);
INSERT INTO SUPPLIER VALUES(44288,’ORDVA, Inc.’ ,’615′,’TN’);
INSERT INTO SUPPLIER VALUES(55443,’BK, Inc.’ ,’904′,’FL’);
INSERT INTO SUPPLIER VALUES(55501,’Damal Supplies’ ,’615′,’TN’);
INSERT INTO SUPPLIER VALUES(55595,’Rubicon Systems’ ,’904′,’FL’);
INSERT INTO PRODUCT VALUES(’11QER/31′,’Power painter, 15 psi., 3-nozzle’ ,’CAT1′,55595);
INSERT INTO PRODUCT VALUES(’13-Q2/P2′,’7.25-in. pwr. saw blade’ ,’CAT1′,31344);
INSERT INTO PRODUCT VALUES(’14-Q1/L3′,’9.00-in. pwr. saw blade’ ,’CAT1′,31344);
INSERT INTO PRODUCT VALUES(‘1546-QQ2′,’Hrd. cloth, 1/4-in., 2×50′ ,’CAT2’,33119);
INSERT INTO PRODUCT VALUES(‘1558-QW1′,’Hrd. cloth, 1/2-in., 3×50′ ,’CAT2’,33119);
INSERT INTO PRODUCT VALUES(‘2232/QTY’,’BD jigsaw, 12-in. blade’ ,’CAT2′,44288);
INSERT INTO PRODUCT VALUES(‘2232/QWE’,’BD jigsaw, 8-in. blade’ ,’CAT3′,44288);
INSERT INTO PRODUCT VALUES(‘2238/QPD’,’BD cordless drill, 1/2-in.’ ,’CAT3′,55595);
INSERT INTO PRODUCT VALUES(‘23109-HB’,’Claw hammer’ ,’CAT4′,31225);
INSERT INTO PRODUCT VALUES(‘23114-AA’,’Sledge hammer, 12 lb.’ ,’CAT4′,31225);
INSERT INTO PRODUCT VALUES(‘54778-2T’,’Rat-tail file, 1/8-in. fine’ ,’CAT1′,31344);
INSERT INTO PRODUCT VALUES(’89-WRE-Q’,’Hicut chain saw, 16 in.’ ,’CAT2′,44288);
INSERT INTO PRODUCT VALUES(‘PVC23DRT’,’PVC pipe, 3.5-in., 8-ft’ ,’CAT3′,31225);
INSERT INTO PRODUCT VALUES(‘SM-18277′,’1.25-in. metal screw, 25′ ,’CAT4’,31225);
INSERT INTO PRODUCT VALUES(‘SW-23116′,’2.5-in. wd. screw, 50′ ,’CAT2’,31231);
INSERT INTO PRODUCT VALUES(‘WR3/TT3′ ,’Steel matting, 4”x8”x1/6″, .5″ mesh’,’CAT3′,55595);
INSERT INTO DISTRICT VALUES(1,’NE’);
INSERT INTO DISTRICT VALUES(2,’NW’);
INSERT INTO DISTRICT VALUES(3,’SE’);
INSERT INTO DISTRICT VALUES(4,’SW’);
INSERT INTO CUSTOMER VALUES(110010,’Ramas’ ,’Alfred’,’A’ ,’TN’,3);
INSERT INTO CUSTOMER VALUES(110011,’Dunne’ ,’Leona’ ,’K’ ,’GA’,3);
INSERT INTO CUSTOMER VALUES(110012,’Smith’ ,’Kathy’ ,’W’ ,’NY’,1);
INSERT INTO CUSTOMER VALUES(110013,’Olowski’ ,’Paul’ ,’F’ ,’NJ’,1);
INSERT INTO CUSTOMER VALUES(110014,’Orlando’ ,’Myron’ ,NULL,’CO’,2);
INSERT INTO CUSTOMER VALUES(110015,’O”Brian’,’Amy’ ,’B’ ,’TN’,3);
INSERT INTO CUSTOMER VALUES(110016,’Brown’ ,’James’ ,’G’ ,’GA’,3);
INSERT INTO CUSTOMER VALUES(110017,’Williams’,’George’,NULL,’CA’,4);
INSERT INTO CUSTOMER VALUES(110018,’Farriss’ ,’Anne’ ,’G’ ,’CA’,4);
INSERT INTO CUSTOMER VALUES(110019,’Smith’ ,’Olette’,’K’ ,’CO’,2);
INSERT INTO TIME VALUES(201,2009,09,29,3);
INSERT INTO TIME VALUES(202,2009,09,30,3);
INSERT INTO TIME VALUES(203,2009,09,31,3);
INSERT INTO TIME VALUES(206,2009,10,03,4);
INSERT INTO TIME VALUES(207,2009,10,04,4);
INSERT INTO SALES VALUES(201,110014,’13-Q2/P2′,1,14.99);
INSERT INTO SALES VALUES(201,110014,’23109-HB’,1,11.95);
INSERT INTO SALES VALUES(201,110015,’54778-2T’,2,5.99);
INSERT INTO SALES VALUES(201,110015,’2238/QPD’,1,38.95);
INSERT INTO SALES VALUES(202,110016,’1546-QQ2′,1,311.95);
INSERT INTO SALES VALUES(202,110016,’13-Q2/P2′,5,15.99);
INSERT INTO SALES VALUES(202,110017,’54778-2T’,3,5.99);
INSERT INTO SALES VALUES(202,110017,’23109-HB’,2,11.95);
INSERT INTO SALES VALUES(202,110018,’PVC23DRT’,12,5.87);
INSERT INTO SALES VALUES(203,110012,’SM-18277′,3,8.95);
INSERT INTO SALES VALUES(203,110014,’2232/QTY’,1,109.92);
INSERT INTO SALES VALUES(203,110015,’23109-HB’,1,11.95);
INSERT INTO SALES VALUES(203,110015,’89-WRE-Q’,1,258.95);
INSERT INTO SALES VALUES(203,110016,’13-Q2/P2′,2,15.99);
INSERT INTO SALES VALUES(203,110016,’54778-2T’,1,5.99);
INSERT INTO SALES VALUES(203,110016,’PVC23DRT’,5,5.87);
INSERT INTO SALES VALUES(203,110017,’WR3/TT3′,3,111.95);
INSERT INTO SALES VALUES(203,110017,’23109-HB’,1,11.95);
INSERT INTO SALES VALUES(203,110017,’13-Q2/P2′,1,15.99);
INSERT INTO SALES VALUES(203,110018,’23109-HB’,1,11.95);
INSERT INTO SALES VALUES(203,110018,’54778-2T’,2,5.99);
INSERT INTO SALES VALUES(203,110018,’2238/QPD’,1,38.95);
INSERT INTO SALES VALUES(203,110019,’1546-QQ2′,1,311.95);
INSERT INTO SALES VALUES(206,110010,’13-Q2/P2′,5,15.99);
INSERT INTO SALES VALUES(206,110010,’54778-2T’,3,5.99);
INSERT INTO SALES VALUES(206,110010,’23109-HB’,2,11.95);
INSERT INTO SALES VALUES(206,110010,’PVC23DRT’,12,5.87);
INSERT INTO SALES VALUES(206,110011,’SM-18277′,3,8.95);
INSERT INTO SALES VALUES(206,110011,’2232/QTY’,1,109.92);
INSERT INTO SALES VALUES(206,110012,’23109-HB’,1,11.95);
INSERT INTO SALES VALUES(206,110012,’89-WRE-Q’,1,258.95);
INSERT INTO SALES VALUES(207,110013,’13-Q2/P2′,2,15.99);
INSERT INTO SALES VALUES(207,110013,’54778-2T’,1,5.99);
INSERT INTO SALES VALUES(207,110013,’PVC23DRT’,5,5.87);
INSERT INTO SALES VALUES(207,110014,’WR3/TT3′,3,111.95);
INSERT INTO SALES VALUES(207,110015,’23109-HB’,1,11.95);
Once the script has finished running, then issue a SHOW TABLES; sql statement. Make sure that you see the following tables listed.
STEP 2: Using the ROLLUP Extension
In this section of the lab you are going to create a sales report that will show a supplier code, product code and the total sales for each product based on unit price times a quantity. More importantly the column that shows the total sales will also show a grand total for the supplier as well as a grand total over all (this will be the last row of data shown). To do this you will use the ROLLUP extension as part of the GROUP BY clause in the query. Use aliases for the column names so that the output columns in the result set look like the following.
SUPPLIER CODE
PRODUCT
TOTAL SALES
31225
23109-HB
119.50
31225
PVC23DRT
199.58
31225
SM-18277
53.70
31225
372.78
31344
13-Q2/P2
254.84
31344
54778-2T
71.88
31344
326.72
33119
1546-QQ2
623.90
33119
623.90
44288
2232/QTY
219.84
44288
89-WRE-Q
517.90
44288
737.74
55595
2238/QPD
77.90
55595
WR3/TT3
671.70
55595
749.60
2810.74
Be sure to copy your SQL code and the result set produced and paste it into the appropriate place in the LAB6_REPORT.
STEP 3: Using the CUBE Extension
In this section of the lab you are going to examine the creation of a sales report that will show a month code, product code and the total sales for each product based on unit price times a quantity. At the time of this writing, MySQL does not implement the CUBE clause, so we will study an example constructed using the ORACLE DBMS. In this report, the column that shows the total sales will also show a subtotal for each month (in this case representing a quarter). Following the monthly totals for each product and the subtotal by month then the report will list a total for each product sold during the period with a grand total for all sales during the period (this will be the last row of data shown). To do this, the CUBE extension is used as part of the GROUP BY clause in the query. Aliases are used for the column names so that the output columns in the result set look like the following.
MONTH PRODUCT TOTAL SALES
———- ———- ———–
9 13-Q2/P2 142.91
9 1546-QQ2 623.9
9 2232/QTY 109.92
9 2238/QPD 77.9
9 23109-HB 71.7
9 54778-2T 47.92
9 89-WRE-Q 258.95
9 PVC23DRT 99.79
9 SM-18277 26.85
9 WR3/TT3 335.85
9 1795.69
MONTH PRODUCT TOTAL SALES
———- ———- ———–
10 13-Q2/P2 111.93
10 2232/QTY 109.92
10 23109-HB 47.8
10 54778-2T 23.96
10 89-WRE-Q 258.95
10 PVC23DRT 99.79
10 SM-18277 26.85
10 WR3/TT3 335.85
10 1015.05
13-Q2/P2 254.84
1546-QQ2 623.9
MONTH PRODUCT TOTAL SALES
———- ———- ———–
2232/QTY 219.84
2238/QPD 77.9
23109-HB 119.5
54778-2T 71.88
89-WRE-Q 517.9
PVC23DRT 199.58
SM-18277 53.7
WR3/TT3 671.7
2810.74
31 rows selected.
Here is the ORACLE PL/SQL query which generated these results. Please study the example carefully.
SQL> SELECT T.TIME_MONTH AS “MONTH”, P.PROD_COD
2 SUM(S.SALE_UNITS*S.SALE_PRICE) AS “TOTAL S
3 FROM SALES S, PRODUCT P, TIME T
4 WHERE S.TIME_ID = T.TIME_ID
5 AND S.PROD_CODE = P.PROD_CODE
6 GROUP BY CUBE (T.TIME_MONTH, P.PROD_CODE)
7 ORDER BY T.TIME_MONTH, P.PROD_CODE;
NOTE: This query will produce the same results using NATURAL JOIN.
SELECT TIME_MONTH AS “MONTH”, PROD_CODE AS “PRODUCT”, SUM(SALE_UNITS*SALE_PRICE) AS “TOTAL SALES”
FROM TIME NATURAL JOIN SALES NATURAL JOIN PRODUCT
GROUP BY CUBE (TIME_MONTH, PROD_CODE)
ORDER BY TIME_MONTH, PROD_CODE;
Notice that this report uses the SALES, PRODUCT and TIME tables. It is also possible to write the query using NATURAL JOIN but some developers may feel more comfortable using a traditional JOIN method that will work just as well. Notice that the grand total amount of 2810.74 is the same total as in step 2.
CHECKPOINT QUESTION: Research Data Warehouse Solutions that may be integrated into MySQL enterprise architecture (e.g., PENTAHO). Explain how these solutions may be employed to overcome the current limitations in MySQL support for OLAP functionality. Pay special attention to the reporting and analytic capabilities of these solutions. Based on your analysis and research, do you believe that analytic functions such as GROUP BY CUBE are best implemented in the database (MySQL), the Data Warehouse and Reporting Engine (e.g., PENTAHO), or both. Fully explain your analysis and conclusions.
STEP 4: Materialized Views and a Refresh Procedure
Materialized views (MVs), sometimes referred to as snapshots are a very important aspect of dealing with data when doing data mining or working with a data warehouse. Unlike regular views, a materialized view does not always automatically react to changes made in the base tables of the view. In database systems that directly implement MVs, a Materialized View Log must be created on each base table that will be used in the view. As discussed and explored briefly at the conclusion of Lab 5, MySQL does not directly implement materialized views, but these may be effectively emulated using tables constructed with the same attributes as the view, provided that steps are taken to ensure the automatic update or refresh of the table. For instructional purposes, we will accomplish this by the simple expedient of creating a stored procedure which will drop, recreate, and rebuild the table serving as the view. In our exploration of the concept of the materialized view, we are going to create we are going to use the TIME and the SALES tables.
Because we will emulate an MV in our solution, we will craft a stored procedure to update the MV.
Create and install a stored procedure, named REFRESH_MV_SALESBYMONTH, using the following SQL SELECT statement to guide you. This SELECT statement demonstrates the data to be selected to populate the table. Your stored procedure must: (1) drop the table if it exists; and (2) SELECT INTO the table MV_SALESBYMONTH to create and populate it. Note that, with this logic, no separate logic is needed to first create the view—simply run the stored procedure. The details of the implementation are left to you.
SELECT TIME_YEAR AS “YEAR”, TIME_MONTH AS “MONTH”, PROD_CODE AS “PRODUCT”,
SUM(SALE_UNITS) AS “UNITS SOLD”, SUM(SALE_UNITS*SALE_PRICE) AS “SALES TOTAL”
FROM TIME T, SALES S
WHERE S.TIME_ID = T.TIME_ID
GROUP BY TIME_YEAR, TIME_MONTH, PROD_CODE;
Be sure to copy your SQL code and the result set produced and paste it into the appropriate place in the LAB6_REPORT.
STEP 5: Using the Materialized View
First, CALL REFRESH_MV_SALESBYMONTH. This will make sure that the view is created, and currently up-to-date.
Run the SQL statement: SELECT * FROM MV_SALESBYMONTH. The output columns from your view should look similar to the following (use aliases to format the column headings) and you should have 18 rows in the result set.
YEAR MONTH PRODUCT CO UNITS SOLD SALES TOTAL
Now we are going to add some data and update the view. Remember, we must manually run the stored procedure to update the view, as it will not (yet!) automatically itself.
To begin with, insert the following data into the SALES table—(207, 110016, ‘SM-18277’,1,8.95).
CALL the stored procedure to refresh the view.
Query the view once again.
You should now see that the row for units sold in month 10 for SM-18277 has increased from 3 to 4 and total sales amount has gone from 26.85 to 35.80.
Delete the row you just added to the SALES table, and call the stored procedure to refresh the view, proving that things are up-to-date.
Create a Trigger on the SALES table so that any insert automatically fires off the stored procedure to update the view.
Test your trigger, by again inserting the following data into the SALES table—(207, 110016, ‘SM-18277’,1,8.95).
Query the view once again.
You should now see that the row for units sold in month 10 for SM-18277 has increased from 3 to 4 and total sales amount has gone from 26.85 to 35.80.
CHECKPOINT QUESTION: For instructional purposes and simplicity, we have indulged in the expedient of dropping and recreating the entire MV_SALESBYMONTH table, which now occurs each time a new record is inserted on the SALES table. Would this be unacceptable in practice? Explain why or why not. What other events, and what other tables would require wire-up of triggers in order to ensure that the view is kept up-to-date at all times?
Be sure to copy your SQL code and the result set produced and paste it into the appropriate place in the LAB6_REPORT.
Laboratory Report DeVry University College of Engineering and Information Sciences
Course Number: DBM449
Laboratory Number: 3
Laboratory Title: SWL Analytical Extensions & Materialized Views
Note: There is no limit on how much information you will enter under the three topics below. It is important to be clear and complete with your comments. Like a scientist you are documenting your progress in this week’s lab experiment.
Objectives: (In your own words what was this lab designed to accomplish? What was its purpose?)
Results: (Discuss the steps you used to complete your lab. Were you successful? What did you learn? What were the results? Explain what you did to accomplish each step. You can include screen shots, code listings, and so on. to clearly explain what you did. Be sure to record all results specifically directed by the lab procedure. Number all results to reflect the procedure number to which they correspond.)
Conclusions: (After completing this lab, in your own words, what conclusions can you draw from this experience?)
0 notes
Text
DBM 449 Laboratory Procedures iLab 6 Answers
Follow Below Link to Download Tutorial
https://homeworklance.com/downloads/dbm-449-laboratory-procedures-ilab-6-answers/
For More Information Visit Our Website ( https://homeworklance.com/ )
Email us At: [email protected] or [email protected]
I. OBJECTIVES
Understand and become familiar with the SQL Analytical Extensions.
Learn to create, use, and maintain materialized views, and their functional equivalents.
Effectively apply Advanced Aggregate SQL Operations, such as GROUP BY ROLLUP to solve business intelligence questions and analytical processing problems.
II. PARTS LIST
EDUPE-VT Omnymbus Virtual Machine Environment (https://devry.edupe.net:9090/) and/or:
MySQL (dev.mysql.com/downloads)
III. PROCEDURE
Scenario and Summary
For the lab this week, we are going to look at how the ROLLUP and CUBE extensions available in SQL can be used to create query result sets that have more than one dimension to them. Both of these extensions are used in conjunction with the GROUP BY clause and allow for a much broader look at the data.
To record your work for this lab use the lab report found at the end of this document. As in your previous labs, you will need to copy/paste your SQL statements and results into this document. Upon completion and prior to the due date, submit this document to the appropriate Dropbox.
iLAB STEPS
STEP 1: Setting Up
For this lab you will be using a different user and set of tables than you have used so far for other labs. To set up your instance you will need to do the following.
The first thing you will do for this lab is to run the following SQL Script. Begin by creating the DBM449Lab6 Schema, and creating any user accounts and privileges you wish to use (at least one).
Run the following script to create and populate a set of tables that will be used for this lab. Instructions for this are outlined in Step 1.
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=’TRADITIONAL,ALLOW_INVALID_DATES’;
USE `DBM449Lab6` ;
— —————————————————–
— Table `DBM449Lab6`.`DISTRICT`
— —————————————————–
DROP TABLE IF EXISTS `DBM449Lab6`.`DISTRICT` ;
CREATE TABLE IF NOT EXISTS `DBM449Lab6`.`DISTRICT` (
`DIST_ID` INT(11) NOT NULL,
`DIST_NAME` VARCHAR(10) NULL DEFAULT NULL,
PRIMARY KEY (`DIST_ID`))
ENGINE = InnoDB;
— —————————————————–
— Table `DBM449Lab6`.`CUSTOMER`
— —————————————————–
DROP TABLE IF EXISTS `DBM449Lab6`.`CUSTOMER` ;
CREATE TABLE IF NOT EXISTS `DBM449Lab6`.`CUSTOMER` (
`CUST_CODE` DECIMAL(10,0) NOT NULL,
`CUST_LNAME` VARCHAR(15) NULL DEFAULT NULL,
`CUST_FNAME` VARCHAR(15) NULL DEFAULT NULL,
`CUST_INITIAL` CHAR(1) NULL DEFAULT NULL,
`CUST_STATE` CHAR(2) NULL DEFAULT NULL,
`DIST_ID` INT(11) NOT NULL,
PRIMARY KEY (`CUST_CODE`),
CONSTRAINT `fk_CUSTOMER_DISTRICT1`
FOREIGN KEY (`DIST_ID`)
REFERENCES `DBM449Lab6`.`DISTRICT` (`DIST_ID`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
CREATE INDEX `fk_CUSTOMER_DISTRICT1_idx` ON `DBM449Lab6`.`CUSTOMER` (`DIST_ID` ASC);
— —————————————————–
— Table `DBM449Lab6`.`SUPPLIER`
— —————————————————–
DROP TABLE IF EXISTS `DBM449Lab6`.`SUPPLIER` ;
CREATE TABLE IF NOT EXISTS `DBM449Lab6`.`SUPPLIER` (
`SUP_CODE` INT(11) NOT NULL,
`SUP_NAME` VARCHAR(35) NULL DEFAULT NULL,
`SUP_AREACODE` CHAR(3) NULL DEFAULT NULL,
`SUP_STATE` CHAR(2) NULL DEFAULT NULL,
PRIMARY KEY (`SUP_CODE`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
— —————————————————–
— Table `DBM449Lab6`.`PRODUCT`
— —————————————————–
DROP TABLE IF EXISTS `DBM449Lab6`.`PRODUCT` ;
CREATE TABLE IF NOT EXISTS `DBM449Lab6`.`PRODUCT` (
`PROD_CODE` VARCHAR(10) NOT NULL,
`PROD_DESCRIPT` VARCHAR(35) NULL DEFAULT NULL,
`PROD_CATEGORY` VARCHAR(5) NULL DEFAULT NULL,
`SUP_CODE` INT(11) NOT NULL,
PRIMARY KEY (`PROD_CODE`),
CONSTRAINT `fk_PRODUCT_SUPPLIER`
FOREIGN KEY (`SUP_CODE`)
REFERENCES `DBM449Lab6`.`SUPPLIER` (`SUP_CODE`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
CREATE INDEX `fk_PRODUCT_SUPPLIER_idx` ON `DBM449Lab6`.`PRODUCT` (`SUP_CODE` ASC);
— —————————————————–
— Table `DBM449Lab6`.`SALES`
— —————————————————–
DROP TABLE IF EXISTS `DBM449Lab6`.`SALES` ;
CREATE TABLE IF NOT EXISTS `DBM449Lab6`.`SALES` (
`TIME_ID` DECIMAL(10,0) NOT NULL DEFAULT ‘0’,
`CUST_CODE` DECIMAL(10,0) NOT NULL DEFAULT ‘0’,
`PROD_CODE` VARCHAR(10) NOT NULL DEFAULT ”,
`SALE_UNITS` DECIMAL(10,0) NULL DEFAULT NULL,
`SALE_PRICE` DECIMAL(10,2) NULL DEFAULT NULL,
PRIMARY KEY (`TIME_ID`, `CUST_CODE`, `PROD_CODE`))
ENGINE = InnoDB;
— —————————————————–
— Table `DBM449Lab6`.`TIME`
— —————————————————–
DROP TABLE IF EXISTS `DBM449Lab6`.`TIME` ;
CREATE TABLE IF NOT EXISTS `DBM449Lab6`.`TIME` (
`TIME_ID` INT(11) NOT NULL,
`TIME_YEAR` INT(11) NULL DEFAULT NULL,
`TIME_MONTH` INT(11) NULL DEFAULT NULL,
`TIME_DAY` INT(11) NULL DEFAULT NULL,
`TIME_QTR` INT(11) NULL DEFAULT NULL,
PRIMARY KEY (`TIME_ID`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
INSERT INTO SUPPLIER VALUES(31225,’Bryson, Inc.’ ,’615′,’TN’);
INSERT INTO SUPPLIER VALUES(31226,’SuperLoo, Inc.’ ,’904′,’FL’);
INSERT INTO SUPPLIER VALUES(31231,’DE Supply’ ,’615′,’TN’);
INSERT INTO SUPPLIER VALUES(31344,’Gomez Bros.’ ,’615′,’KY’);
INSERT INTO SUPPLIER VALUES(32567,’Dome Supply’ ,’901′,’GA’);
INSERT INTO SUPPLIER VALUES(33119,’Randsets Ltd.’ ,’901′,’GA’);
INSERT INTO SUPPLIER VALUES(44004,’Brackman Bros.’ ,’615′,’TN’);
INSERT INTO SUPPLIER VALUES(44288,’ORDVA, Inc.’ ,’615′,’TN’);
INSERT INTO SUPPLIER VALUES(55443,’BK, Inc.’ ,’904′,’FL’);
INSERT INTO SUPPLIER VALUES(55501,’Damal Supplies’ ,’615′,’TN’);
INSERT INTO SUPPLIER VALUES(55595,’Rubicon Systems’ ,’904′,’FL’);
INSERT INTO PRODUCT VALUES(’11QER/31′,’Power painter, 15 psi., 3-nozzle’ ,’CAT1′,55595);
INSERT INTO PRODUCT VALUES(’13-Q2/P2′,’7.25-in. pwr. saw blade’ ,’CAT1′,31344);
INSERT INTO PRODUCT VALUES(’14-Q1/L3′,’9.00-in. pwr. saw blade’ ,’CAT1′,31344);
INSERT INTO PRODUCT VALUES(‘1546-QQ2′,’Hrd. cloth, 1/4-in., 2×50′ ,’CAT2’,33119);
INSERT INTO PRODUCT VALUES(‘1558-QW1′,’Hrd. cloth, 1/2-in., 3×50′ ,’CAT2’,33119);
INSERT INTO PRODUCT VALUES(‘2232/QTY’,’BD jigsaw, 12-in. blade’ ,’CAT2′,44288);
INSERT INTO PRODUCT VALUES(‘2232/QWE’,’BD jigsaw, 8-in. blade’ ,’CAT3′,44288);
INSERT INTO PRODUCT VALUES(‘2238/QPD’,’BD cordless drill, 1/2-in.’ ,’CAT3′,55595);
INSERT INTO PRODUCT VALUES(‘23109-HB’,’Claw hammer’ ,’CAT4′,31225);
INSERT INTO PRODUCT VALUES(‘23114-AA’,’Sledge hammer, 12 lb.’ ,’CAT4′,31225);
INSERT INTO PRODUCT VALUES(‘54778-2T’,’Rat-tail file, 1/8-in. fine’ ,’CAT1′,31344);
INSERT INTO PRODUCT VALUES(’89-WRE-Q’,’Hicut chain saw, 16 in.’ ,’CAT2′,44288);
INSERT INTO PRODUCT VALUES(‘PVC23DRT’,’PVC pipe, 3.5-in., 8-ft’ ,’CAT3′,31225);
INSERT INTO PRODUCT VALUES(‘SM-18277′,’1.25-in. metal screw, 25′ ,’CAT4’,31225);
INSERT INTO PRODUCT VALUES(‘SW-23116′,’2.5-in. wd. screw, 50′ ,’CAT2’,31231);
INSERT INTO PRODUCT VALUES(‘WR3/TT3′ ,’Steel matting, 4”x8”x1/6″, .5″ mesh’,’CAT3′,55595);
INSERT INTO DISTRICT VALUES(1,’NE’);
INSERT INTO DISTRICT VALUES(2,’NW’);
INSERT INTO DISTRICT VALUES(3,’SE’);
INSERT INTO DISTRICT VALUES(4,’SW’);
INSERT INTO CUSTOMER VALUES(110010,’Ramas’ ,’Alfred’,’A’ ,’TN’,3);
INSERT INTO CUSTOMER VALUES(110011,’Dunne’ ,’Leona’ ,’K’ ,’GA’,3);
INSERT INTO CUSTOMER VALUES(110012,’Smith’ ,’Kathy’ ,’W’ ,’NY’,1);
INSERT INTO CUSTOMER VALUES(110013,’Olowski’ ,’Paul’ ,’F’ ,’NJ’,1);
INSERT INTO CUSTOMER VALUES(110014,’Orlando’ ,’Myron’ ,NULL,’CO’,2);
INSERT INTO CUSTOMER VALUES(110015,’O”Brian’,’Amy’ ,’B’ ,’TN’,3);
INSERT INTO CUSTOMER VALUES(110016,’Brown’ ,’James’ ,’G’ ,’GA’,3);
INSERT INTO CUSTOMER VALUES(110017,’Williams’,’George’,NULL,’CA’,4);
INSERT INTO CUSTOMER VALUES(110018,’Farriss’ ,’Anne’ ,’G’ ,’CA’,4);
INSERT INTO CUSTOMER VALUES(110019,’Smith’ ,’Olette’,’K’ ,’CO’,2);
INSERT INTO TIME VALUES(201,2009,09,29,3);
INSERT INTO TIME VALUES(202,2009,09,30,3);
INSERT INTO TIME VALUES(203,2009,09,31,3);
INSERT INTO TIME VALUES(206,2009,10,03,4);
INSERT INTO TIME VALUES(207,2009,10,04,4);
INSERT INTO SALES VALUES(201,110014,’13-Q2/P2′,1,14.99);
INSERT INTO SALES VALUES(201,110014,’23109-HB’,1,11.95);
INSERT INTO SALES VALUES(201,110015,’54778-2T’,2,5.99);
INSERT INTO SALES VALUES(201,110015,’2238/QPD’,1,38.95);
INSERT INTO SALES VALUES(202,110016,’1546-QQ2′,1,311.95);
INSERT INTO SALES VALUES(202,110016,’13-Q2/P2′,5,15.99);
INSERT INTO SALES VALUES(202,110017,’54778-2T’,3,5.99);
INSERT INTO SALES VALUES(202,110017,’23109-HB’,2,11.95);
INSERT INTO SALES VALUES(202,110018,’PVC23DRT’,12,5.87);
INSERT INTO SALES VALUES(203,110012,’SM-18277′,3,8.95);
INSERT INTO SALES VALUES(203,110014,’2232/QTY’,1,109.92);
INSERT INTO SALES VALUES(203,110015,’23109-HB’,1,11.95);
INSERT INTO SALES VALUES(203,110015,’89-WRE-Q’,1,258.95);
INSERT INTO SALES VALUES(203,110016,’13-Q2/P2′,2,15.99);
INSERT INTO SALES VALUES(203,110016,’54778-2T’,1,5.99);
INSERT INTO SALES VALUES(203,110016,’PVC23DRT’,5,5.87);
INSERT INTO SALES VALUES(203,110017,’WR3/TT3′,3,111.95);
INSERT INTO SALES VALUES(203,110017,’23109-HB’,1,11.95);
INSERT INTO SALES VALUES(203,110017,’13-Q2/P2′,1,15.99);
INSERT INTO SALES VALUES(203,110018,’23109-HB’,1,11.95);
INSERT INTO SALES VALUES(203,110018,’54778-2T’,2,5.99);
INSERT INTO SALES VALUES(203,110018,’2238/QPD’,1,38.95);
INSERT INTO SALES VALUES(203,110019,’1546-QQ2′,1,311.95);
INSERT INTO SALES VALUES(206,110010,’13-Q2/P2′,5,15.99);
INSERT INTO SALES VALUES(206,110010,’54778-2T’,3,5.99);
INSERT INTO SALES VALUES(206,110010,’23109-HB’,2,11.95);
INSERT INTO SALES VALUES(206,110010,’PVC23DRT’,12,5.87);
INSERT INTO SALES VALUES(206,110011,’SM-18277′,3,8.95);
INSERT INTO SALES VALUES(206,110011,’2232/QTY’,1,109.92);
INSERT INTO SALES VALUES(206,110012,’23109-HB’,1,11.95);
INSERT INTO SALES VALUES(206,110012,’89-WRE-Q’,1,258.95);
INSERT INTO SALES VALUES(207,110013,’13-Q2/P2′,2,15.99);
INSERT INTO SALES VALUES(207,110013,’54778-2T’,1,5.99);
INSERT INTO SALES VALUES(207,110013,’PVC23DRT’,5,5.87);
INSERT INTO SALES VALUES(207,110014,’WR3/TT3′,3,111.95);
INSERT INTO SALES VALUES(207,110015,’23109-HB’,1,11.95);
Once the script has finished running, then issue a SHOW TABLES; sql statement. Make sure that you see the following tables listed.
STEP 2: Using the ROLLUP Extension
In this section of the lab you are going to create a sales report that will show a supplier code, product code and the total sales for each product based on unit price times a quantity. More importantly the column that shows the total sales will also show a grand total for the supplier as well as a grand total over all (this will be the last row of data shown). To do this you will use the ROLLUP extension as part of the GROUP BY clause in the query. Use aliases for the column names so that the output columns in the result set look like the following.
SUPPLIER CODE
PRODUCT
TOTAL SALES
31225
23109-HB
119.50
31225
PVC23DRT
199.58
31225
SM-18277
53.70
31225
372.78
31344
13-Q2/P2
254.84
31344
54778-2T
71.88
31344
326.72
33119
1546-QQ2
623.90
33119
623.90
44288
2232/QTY
219.84
44288
89-WRE-Q
517.90
44288
737.74
55595
2238/QPD
77.90
55595
WR3/TT3
671.70
55595
749.60
2810.74
Be sure to copy your SQL code and the result set produced and paste it into the appropriate place in the LAB6_REPORT.
STEP 3: Using the CUBE Extension
In this section of the lab you are going to examine the creation of a sales report that will show a month code, product code and the total sales for each product based on unit price times a quantity. At the time of this writing, MySQL does not implement the CUBE clause, so we will study an example constructed using the ORACLE DBMS. In this report, the column that shows the total sales will also show a subtotal for each month (in this case representing a quarter). Following the monthly totals for each product and the subtotal by month then the report will list a total for each product sold during the period with a grand total for all sales during the period (this will be the last row of data shown). To do this, the CUBE extension is used as part of the GROUP BY clause in the query. Aliases are used for the column names so that the output columns in the result set look like the following.
MONTH PRODUCT TOTAL SALES
———- ———- ———–
9 13-Q2/P2 142.91
9 1546-QQ2 623.9
9 2232/QTY 109.92
9 2238/QPD 77.9
9 23109-HB 71.7
9 54778-2T 47.92
9 89-WRE-Q 258.95
9 PVC23DRT 99.79
9 SM-18277 26.85
9 WR3/TT3 335.85
9 1795.69
MONTH PRODUCT TOTAL SALES
———- ———- ———–
10 13-Q2/P2 111.93
10 2232/QTY 109.92
10 23109-HB 47.8
10 54778-2T 23.96
10 89-WRE-Q 258.95
10 PVC23DRT 99.79
10 SM-18277 26.85
10 WR3/TT3 335.85
10 1015.05
13-Q2/P2 254.84
1546-QQ2 623.9
MONTH PRODUCT TOTAL SALES
———- ———- ———–
2232/QTY 219.84
2238/QPD 77.9
23109-HB 119.5
54778-2T 71.88
89-WRE-Q 517.9
PVC23DRT 199.58
SM-18277 53.7
WR3/TT3 671.7
2810.74
31 rows selected.
Here is the ORACLE PL/SQL query which generated these results. Please study the example carefully.
SQL> SELECT T.TIME_MONTH AS “MONTH”, P.PROD_COD
2 SUM(S.SALE_UNITS*S.SALE_PRICE) AS “TOTAL S
3 FROM SALES S, PRODUCT P, TIME T
4 WHERE S.TIME_ID = T.TIME_ID
5 AND S.PROD_CODE = P.PROD_CODE
6 GROUP BY CUBE (T.TIME_MONTH, P.PROD_CODE)
7 ORDER BY T.TIME_MONTH, P.PROD_CODE;
NOTE: This query will produce the same results using NATURAL JOIN.
SELECT TIME_MONTH AS “MONTH”, PROD_CODE AS “PRODUCT”, SUM(SALE_UNITS*SALE_PRICE) AS “TOTAL SALES”
FROM TIME NATURAL JOIN SALES NATURAL JOIN PRODUCT
GROUP BY CUBE (TIME_MONTH, PROD_CODE)
ORDER BY TIME_MONTH, PROD_CODE;
Notice that this report uses the SALES, PRODUCT and TIME tables. It is also possible to write the query using NATURAL JOIN but some developers may feel more comfortable using a traditional JOIN method that will work just as well. Notice that the grand total amount of 2810.74 is the same total as in step 2.
CHECKPOINT QUESTION: Research Data Warehouse Solutions that may be integrated into MySQL enterprise architecture (e.g., PENTAHO). Explain how these solutions may be employed to overcome the current limitations in MySQL support for OLAP functionality. Pay special attention to the reporting and analytic capabilities of these solutions. Based on your analysis and research, do you believe that analytic functions such as GROUP BY CUBE are best implemented in the database (MySQL), the Data Warehouse and Reporting Engine (e.g., PENTAHO), or both. Fully explain your analysis and conclusions.
STEP 4: Materialized Views and a Refresh Procedure
Materialized views (MVs), sometimes referred to as snapshots are a very important aspect of dealing with data when doing data mining or working with a data warehouse. Unlike regular views, a materialized view does not always automatically react to changes made in the base tables of the view. In database systems that directly implement MVs, a Materialized View Log must be created on each base table that will be used in the view. As discussed and explored briefly at the conclusion of Lab 5, MySQL does not directly implement materialized views, but these may be effectively emulated using tables constructed with the same attributes as the view, provided that steps are taken to ensure the automatic update or refresh of the table. For instructional purposes, we will accomplish this by the simple expedient of creating a stored procedure which will drop, recreate, and rebuild the table serving as the view. In our exploration of the concept of the materialized view, we are going to create we are going to use the TIME and the SALES tables.
Because we will emulate an MV in our solution, we will craft a stored procedure to update the MV.
Create and install a stored procedure, named REFRESH_MV_SALESBYMONTH, using the following SQL SELECT statement to guide you. This SELECT statement demonstrates the data to be selected to populate the table. Your stored procedure must: (1) drop the table if it exists; and (2) SELECT INTO the table MV_SALESBYMONTH to create and populate it. Note that, with this logic, no separate logic is needed to first create the view—simply run the stored procedure. The details of the implementation are left to you.
SELECT TIME_YEAR AS “YEAR”, TIME_MONTH AS “MONTH”, PROD_CODE AS “PRODUCT”,
SUM(SALE_UNITS) AS “UNITS SOLD”, SUM(SALE_UNITS*SALE_PRICE) AS “SALES TOTAL”
FROM TIME T, SALES S
WHERE S.TIME_ID = T.TIME_ID
GROUP BY TIME_YEAR, TIME_MONTH, PROD_CODE;
Be sure to copy your SQL code and the result set produced and paste it into the appropriate place in the LAB6_REPORT.
STEP 5: Using the Materialized View
First, CALL REFRESH_MV_SALESBYMONTH. This will make sure that the view is created, and currently up-to-date.
Run the SQL statement: SELECT * FROM MV_SALESBYMONTH. The output columns from your view should look similar to the following (use aliases to format the column headings) and you should have 18 rows in the result set.
YEAR MONTH PRODUCT CO UNITS SOLD SALES TOTAL
Now we are going to add some data and update the view. Remember, we must manually run the stored procedure to update the view, as it will not (yet!) automatically itself.
To begin with, insert the following data into the SALES table—(207, 110016, ‘SM-18277’,1,8.95).
CALL the stored procedure to refresh the view.
Query the view once again.
You should now see that the row for units sold in month 10 for SM-18277 has increased from 3 to 4 and total sales amount has gone from 26.85 to 35.80.
Delete the row you just added to the SALES table, and call the stored procedure to refresh the view, proving that things are up-to-date.
Create a Trigger on the SALES table so that any insert automatically fires off the stored procedure to update the view.
Test your trigger, by again inserting the following data into the SALES table—(207, 110016, ‘SM-18277’,1,8.95).
Query the view once again.
You should now see that the row for units sold in month 10 for SM-18277 has increased from 3 to 4 and total sales amount has gone from 26.85 to 35.80.
CHECKPOINT QUESTION: For instructional purposes and simplicity, we have indulged in the expedient of dropping and recreating the entire MV_SALESBYMONTH table, which now occurs each time a new record is inserted on the SALES table. Would this be unacceptable in practice? Explain why or why not. What other events, and what other tables would require wire-up of triggers in order to ensure that the view is kept up-to-date at all times?
Be sure to copy your SQL code and the result set produced and paste it into the appropriate place in the LAB6_REPORT.
Laboratory Report DeVry University College of Engineering and Information Sciences
Course Number: DBM449
Laboratory Number: 3
Laboratory Title: SWL Analytical Extensions & Materialized Views
Note: There is no limit on how much information you will enter under the three topics below. It is important to be clear and complete with your comments. Like a scientist you are documenting your progress in this week’s lab experiment.
Objectives: (In your own words what was this lab designed to accomplish? What was its purpose?)
Results: (Discuss the steps you used to complete your lab. Were you successful? What did you learn? What were the results? Explain what you did to accomplish each step. You can include screen shots, code listings, and so on. to clearly explain what you did. Be sure to record all results specifically directed by the lab procedure. Number all results to reflect the procedure number to which they correspond.)
Conclusions: (After completing this lab, in your own words, what conclusions can you draw from this experience?)
0 notes
Text
DBM 449 devry Ilab 5 assignment
Follow Below Link to Download Tutorial
https://homeworklance.com/downloads/dbm-449-devry-ilab-5-assignment/
For More Information Visit Our Website ( https://homeworklance.com/ )
Email us At: [email protected] or [email protected]
Laboratory Procedures DeVry University College of Engineering and Information Sciences
I. OBJECTIVES
Understand and become familiar with fundamentals of DBMS security monitoring, auditing, logging, alerting, and reporting.
Install and configure a MySQL database.
Install and configure an Audit and Security module for MySQL database.
Generate logged events, and inspect contents of an Audit Log.
II. PARTS LIST
EDUPE-VT Omnymbus Virtual Machine Environment (https://devry.edupe.net:9090/) and/or:
MySQL (dev.mysql.com/downloads)
III. PROCEDURE, Part A—Installing MySQL
In order to complete this lab, you will require full control over a LINUX host operating system into which you will install and configure the MySQL database engine. You may achieve this through the DeVry iLab environment (https://devry.edupe.net:9090/), or by installing MySQL onto your own LINUX-based computer, or even into a LINUX Virtual Machine (VM) running in a VM environment on your own computer, such as VMWARE Player, or Sun’s Virtual Box. Full instructions for installing and configuring your own VM environment are beyond the scope of this lab, so unless you have prior experience with VM’s, using the DeVry iLab or installing onto your own LINUX-based computer is recommended.
Preliminary Configuration (DeVry iLab environment only)
Log into the DeVry Omnymbus EDUPE-VT environment, https://devry.edupe.net:9090/.
Create a single VM, using Template #6: VMX-LINUX-DESKTOP-UBUNTU. While you might presume that you should choose SERVER instead of DESKTOP, the DESKTOP VM image provides many tools running from the Graphical User Interface (GUI), which you may find convenient, especially if your experience in LINUX Operating System environments is limited.
Complete all steps required by Omnymbus to complete the configuration of your LINUX host, such as changing the root password and host name. Make a note of the IP address assigned to your new VM, for future use when managing or using your VM instance.
MySQL Database Installation (all environments)
Install the current release (general, not beta) of MySQL. If you are using UBUNTU LINUX, you may do this from the UBUNTU SOFTWARE CENTER, found under APPLICATIONS on the desktop. For other versions of LINUX, research available methods for downloading and �� installing MySQL appropriate to your Operating System. These might include APT-GET, RedHat Package Manager (RPM), YUM, and so on.
Configure and test that your MySQL service. Be sure that the services have started, and that you are able to connect to MySQL. This may be done in a terminal session using a command line statement, such as: mysql –host=localhost –user=myname –password mydb. Alternatively, you may choose to download and install a GUI SQL administration tool, such as TORA or MySQL Workbench. The command line is installed by default; the GUI tools are optional.
Take a screenshot of your successful connection to your MySQL database, and paste this into your lab report.
We will need a database later, in order to test the audit logging of events we choose to monitor. Just about any trivial database, with a little bit of data in it will suffice. You may use SQL scripts from previous labs, or use the Internet to search for and obtain a copy of the scripts to create and populate the SAKILA sample database. Choose whatever method and schema you wish, and run the scripts to create and populate some tables. Test your data model briefly by issuing a SELECT * from one of the tables. Paste a screen shot showing the successful SELECT and the first five or six rows of the result into your lab report.
McAfee Audit Module Download and Installation (all environments)
CHECKPOINT QUESTION: In order to proceed with the installation of the McAfee Audit Plugin for MySQL, you will need to gather some additional information. These checkpoint questions will help you to clarify this task: What version of LINUX are you running, and how do you determine this? Are you running a 32-bit or 64-bit version of the Operating system, and how do you determine this? How can you obtain/Where can you download an appropriate version of the McAfee Audit Plugin for your use? Once downloaded, how do you unpack the package to access the plugin components? What is the path of the plugin directory into which you must copy the unpacked/unzipped plugin? Record your answers to these questions, and paste them into your lab report. Download, unpack, and copy all files where they belong. (Hint: If you are unable to find a pre-built installation options through your desktop controls, such as Ubuntu Software Center, you can also download the package using a browser, or by using the wget command line interface statement. This latter statement would begin similar to: sudo wget…)
CHECKPOINT QUESTION: The installation of the plugin is done from within the MySQL console. What is the command you must issue to install the plugin? Record your answer in your lab report.
Issue the MySQL console command to install the plugin.
From the MySQL console, issue the command: show plugins;. Take a screenshot showing your successful results, and paste it into your lab report.
Configuring the McAfee Audit Module (all environments)
CHECKPOINT QUESTION: Even though the McAfee Audit Plugin in now installed, it is not yet monitoring things as we would wish. First, the Plugin must be configured. Research what events the plugin is capable of logging, and how to edit the configuration to log them. What command must be entered or what files edited in order to cause the plugin to log the following events: Connect, Quit, Failed Login, Insert, Drop, Create? Record the exact steps you must take and the commands you must enter in order to begin logging the events specified. Next, consider what actions you would need to take to generate each of these events, and document your plan for doing so. Paste both the configuration steps, and the commands you will execute to test the logging of each event into your lab report.
Execute each of the actions planned in the previous step to generate an event in the audit log.
Determine the location of the audit log (this is commonly /var/lib/mysql/mysql-audit.json). Display the log contents, and analyze them to show that each event you triggered appears in the log. Note: the log file format is not optimized for human readability. The default format generated by this plugin is a .json file, which is easily read and processed for many purposes, including generating pager or system alerts, automated threat responses, as well as reporting. Reporting software that uses such logs is known as Security Information and Event Management (SIEM) software. You may also find utilities that will read and format .json file format into a layout that is easier for humans to read. In any event, take screen shots of your log results, and annotate them to show that each of the required events was captured by the log. Paste a copy of this result into your lab report.
CHECKPOINT QUESTION: What has been achieved by this lab, and what steps would remain to provide a comprehensive security system, including reporting, monitoring, alerting, and Automated Threat Response (automatic countermeasures)? In your answer, give an example of a specific example of each of these, and discuss how it would operate (e.g., an Automated Threat Response might be to disable a user account, or to dynamically add a firewall rule rejecting any further traffic from a specific host computer from which a prohibited event was generated). Record your answer in the lab report.
Laboratory Report DeVry University College of Engineering and Information Sciences
Course Number: DBM449
Laboratory Number: 5
Laboratory Title: Database Security
Note: There is no limit on how much information you will enter under the three topics below. It is important to be clear and complete with your comments. Like a scientist you are documenting your progress in this week’s lab experiment.
Objectives: (In your own words what was this lab designed to accomplish? What was its purpose?)
Results: (Discuss the steps you used to complete your lab. Were you successful? What did you learn? What were the results? Explain what you did to accomplish each step. You can include screen shots, code listings, and so on. to clearly explain what you did. Be sure to record all results specifically directed by the lab procedure. Number all results to reflect the procedure number to which they correspond.)
Conclusions: (After completing this lab, in your own words, what conclusions can you draw from this experience?)
0 notes
Text
DBM 449 devry Ilab 5 assignment
Follow Below Link to Download Tutorial
https://homeworklance.com/downloads/dbm-449-devry-ilab-5-assignment/
For More Information Visit Our Website ( https://homeworklance.com/ )
Email us At: [email protected] or [email protected]
Laboratory Procedures DeVry University College of Engineering and Information Sciences
I. OBJECTIVES
Understand and become familiar with fundamentals of DBMS security monitoring, auditing, logging, alerting, and reporting.
Install and configure a MySQL database.
Install and configure an Audit and Security module for MySQL database.
Generate logged events, and inspect contents of an Audit Log.
II. PARTS LIST
EDUPE-VT Omnymbus Virtual Machine Environment (https://devry.edupe.net:9090/) and/or:
MySQL (dev.mysql.com/downloads)
III. PROCEDURE, Part A—Installing MySQL
In order to complete this lab, you will require full control over a LINUX host operating system into which you will install and configure the MySQL database engine. You may achieve this through the DeVry iLab environment (https://devry.edupe.net:9090/), or by installing MySQL onto your own LINUX-based computer, or even into a LINUX Virtual Machine (VM) running in a VM environment on your own computer, such as VMWARE Player, or Sun’s Virtual Box. Full instructions for installing and configuring your own VM environment are beyond the scope of this lab, so unless you have prior experience with VM’s, using the DeVry iLab or installing onto your own LINUX-based computer is recommended.
Preliminary Configuration (DeVry iLab environment only)
Log into the DeVry Omnymbus EDUPE-VT environment, https://devry.edupe.net:9090/.
Create a single VM, using Template #6: VMX-LINUX-DESKTOP-UBUNTU. While you might presume that you should choose SERVER instead of DESKTOP, the DESKTOP VM image provides many tools running from the Graphical User Interface (GUI), which you may find convenient, especially if your experience in LINUX Operating System environments is limited.
Complete all steps required by Omnymbus to complete the configuration of your LINUX host, such as changing the root password and host name. Make a note of the IP address assigned to your new VM, for future use when managing or using your VM instance.
MySQL Database Installation (all environments)
Install the current release (general, not beta) of MySQL. If you are using UBUNTU LINUX, you may do this from the UBUNTU SOFTWARE CENTER, found under APPLICATIONS on the desktop. For other versions of LINUX, research available methods for downloading and installing MySQL appropriate to your Operating System. These might include APT-GET, RedHat Package Manager (RPM), YUM, and so on.
Configure and test that your MySQL service. Be sure that the services have started, and that you are able to connect to MySQL. This may be done in a terminal session using a command line statement, such as: mysql –host=localhost –user=myname –password mydb. Alternatively, you may choose to download and install a GUI SQL administration tool, such as TORA or MySQL Workbench. The command line is installed by default; the GUI tools are optional.
Take a screenshot of your successful connection to your MySQL database, and paste this into your lab report.
We will need a database later, in order to test the audit logging of events we choose to monitor. Just about any trivial database, with a little bit of data in it will suffice. You may use SQL scripts from previous labs, or use the Internet to search for and obtain a copy of the scripts to create and populate the SAKILA sample database. Choose whatever method and schema you wish, and run the scripts to create and populate some tables. Test your data model briefly by issuing a SELECT * from one of the tables. Paste a screen shot showing the successful SELECT and the first five or six rows of the result into your lab report.
McAfee Audit Module Download and Installation (all environments)
CHECKPOINT QUESTION: In order to proceed with the installation of the McAfee Audit Plugin for MySQL, you will need to gather some additional information. These checkpoint questions will help you to clarify this task: What version of LINUX are you running, and how do you determine this? Are you running a 32-bit or 64-bit version of the Operating system, and how do you determine this? How can you obtain/Where can you download an appropriate version of the McAfee Audit Plugin for your use? Once downloaded, how do you unpack the package to access the plugin components? What is the path of the plugin directory into which you must copy the unpacked/unzipped plugin? Record your answers to these questions, and paste them into your lab report. Download, unpack, and copy all files where they belong. (Hint: If you are unable to find a pre-built installation options through your desktop controls, such as Ubuntu Software Center, you can also download the package using a browser, or by using the wget command line interface statement. This latter statement would begin similar to: sudo wget…)
CHECKPOINT QUESTION: The installation of the plugin is done from within the MySQL console. What is the command you must issue to install the plugin? Record your answer in your lab report.
Issue the MySQL console command to install the plugin.
From the MySQL console, issue the command: show plugins;. Take a screenshot showing your successful results, and paste it into your lab report.
Configuring the McAfee Audit Module (all environments)
CHECKPOINT QUESTION: Even though the McAfee Audit Plugin in now installed, it is not yet monitoring things as we would wish. First, the Plugin must be configured. Research what events the plugin is capable of logging, and how to edit the configuration to log them. What command must be entered or what files edited in order to cause the plugin to log the following events: Connect, Quit, Failed Login, Insert, Drop, Create? Record the exact steps you must take and the commands you must enter in order to begin logging the events specified. Next, consider what actions you would need to take to generate each of these events, and document your plan for doing so. Paste both the configuration steps, and the commands you will execute to test the logging of each event into your lab report.
Execute each of the actions planned in the previous step to generate an event in the audit log.
Determine the location of the audit log (this is commonly /var/lib/mysql/mysql-audit.json). Display the log contents, and analyze them to show that each event you triggered appears in the log. Note: the log file format is not optimized for human readability. The default format generated by this plugin is a .json file, which is easily read and processed for many purposes, including generating pager or system alerts, automated threat responses, as well as reporting. Reporting software that uses such logs is known as Security Information and Event Management (SIEM) software. You may also find utilities that will read and format .json file format into a layout that is easier for humans to read. In any event, take screen shots of your log results, and annotate them to show that each of the required events was captured by the log. Paste a copy of this result into your lab report.
CHECKPOINT QUESTION: What has been achieved by this lab, and what steps would remain to provide a comprehensive security system, including reporting, monitoring, alerting, and Automated Threat Response (automatic countermeasures)? In your answer, give an example of a specific example of each of these, and discuss how it would operate (e.g., an Automated Threat Response might be to disable a user account, or to dynamically add a firewall rule rejecting any further traffic from a specific host computer from which a prohibited event was generated). Record your answer in the lab report.
Laboratory Report DeVry University College of Engineering and Information Sciences
Course Number: DBM449
Laboratory Number: 5
Laboratory Title: Database Security
Note: There is no limit on how much information you will enter under the three topics below. It is important to be clear and complete with your comments. Like a scientist you are documenting your progress in this week’s lab experiment.
Objectives: (In your own words what was this lab designed to accomplish? What was its purpose?)
Results: (Discuss the steps you used to complete your lab. Were you successful? What did you learn? What were the results? Explain what you did to accomplish each step. You can include screen shots, code listings, and so on. to clearly explain what you did. Be sure to record all results specifically directed by the lab procedure. Number all results to reflect the procedure number to which they correspond.)
Conclusions: (After completing this lab, in your own words, what conclusions can you draw from this experience?)
0 notes
Text
DBM 449 devry Ilab 5 assignment
Follow Below Link to Download Tutorial
https://homeworklance.com/downloads/dbm-449-devry-ilab-5-assignment/
For More Information Visit Our Website ( https://homeworklance.com/ )
Email us At: [email protected] or [email protected]
Laboratory Procedures DeVry University College of Engineering and Information Sciences
I. OBJECTIVES
Understand and become familiar with fundamentals of DBMS security monitoring, auditing, logging, alerting, and reporting.
Install and configure a MySQL database.
Install and configure an Audit and Security module for MySQL database.
Generate logged events, and inspect contents of an Audit Log.
II. PARTS LIST
EDUPE-VT Omnymbus Virtual Machine Environment (https://devry.edupe.net:9090/) and/or:
MySQL (dev.mysql.com/downloads)
III. PROCEDURE, Part A—Installing MySQL
In order to complete this lab, you will require full control over a LINUX host operating system into which you will install and configure the MySQL database engine. You may achieve this through the DeVry iLab environment (https://devry.edupe.net:9090/), or by installing MySQL onto your own LINUX-based computer, or even into a LINUX Virtual Machine (VM) running in a VM environment on your own computer, such as VMWARE Player, or Sun’s Virtual Box. Full instructions for installing and configuring your own VM environment are beyond the scope of this lab, so unless you have prior experience with VM’s, using the DeVry iLab or installing onto your own LINUX-based computer is recommended.
Preliminary Configuration (DeVry iLab environment only)
Log into the DeVry Omnymbus EDUPE-VT environment, https://devry.edupe.net:9090/.
Create a single VM, using Template #6: VMX-LINUX-DESKTOP-UBUNTU. While you might presume that you should choose SERVER instead of DESKTOP, the DESKTOP VM image provides many tools running from the Graphical User Interface (GUI), which you may find convenient, especially if your experience in LINUX Operating System environments is limited.
Complete all steps required by Omnymbus to complete the configuration of your LINUX host, such as changing the root password and host name. Make a note of the IP address assigned to your new VM, for future use when managing or using your VM instance.
MySQL Database Installation (all environments)
Install the current release (general, not beta) of MySQL. If you are using UBUNTU LINUX, you may do this from the UBUNTU SOFTWARE CENTER, found under APPLICATIONS on the desktop. For other versions of LINUX, research available methods for downloading and installing MySQL appropriate to your Operating System. These might include APT-GET, RedHat Package Manager (RPM), YUM, and so on.
Configure and test that your MySQL service. Be sure that the services have started, and that you are able to connect to MySQL. This may be done in a terminal session using a command line statement, such as: mysql –host=localhost –user=myname –password mydb. Alternatively, you may choose to download and install a GUI SQL administration tool, such as TORA or MySQL Workbench. The command line is installed by default; the GUI tools are optional.
Take a screenshot of your successful connection to your MySQL database, and paste this into your lab report.
We will need a database later, in order to test the audit logging of events we choose to monitor. Just about any trivial database, with a little bit of data in it will suffice. You may use SQL scripts from previous labs, or use the Internet to search for and obtain a copy of the scripts to create and populate the SAKILA sample database. Choose whatever method and schema you wish, and run the scripts to create and populate some tables. Test your data model briefly by issuing a SELECT * from one of the tables. Paste a screen shot showing the successful SELECT and the first five or six rows of the result into your lab report.
McAfee Audit Module Download and Installation (all environments)
CHECKPOINT QUESTION: In order to proceed with the installation of the McAfee Audit Plugin for MySQL, you will need to gather some additional information. These checkpoint questions will help you to clarify this task: What version of LINUX are you running, and how do you determine this? Are you running a 32-bit or 64-bit version of the Operating system, and how do you determine this? How can you obtain/Where can you download an appropriate version of the McAfee Audit Plugin for your use? Once downloaded, how do you unpack the package to access the plugin components? What is the path of the plugin directory into which you must copy the unpacked/unzipped plugin? Record your answers to these questions, and paste them into your lab report. Download, unpack, and copy all files where they belong. (Hint: If you are unable to find a pre-built installation options through your desktop controls, such as Ubuntu Software Center, you can also download the package using a browser, or by using the wget command line interface statement. This latter statement would begin similar to: sudo wget…)
CHECKPOINT QUESTION: The installation of the plugin is done from within the MySQL console. What is the command you must issue to install the plugin? Record your answer in your lab report.
Issue the MySQL console command to install the plugin.
From the MySQL console, issue the command: show plugins;. Take a screenshot showing your successful results, and paste it into your lab report.
Configuring the McAfee Audit Module (all environments)
CHECKPOINT QUESTION: Even though the McAfee Audit Plugin in now installed, it is not yet monitoring things as we would wish. First, the Plugin must be configured. Research what events the plugin is capable of logging, and how to edit the configuration to log them. What command must be entered or what files edited in order to cause the plugin to log the following events: Connect, Quit, Failed Login, Insert, Drop, Create? Record the exact steps you must take and the commands you must enter in order to begin logging the events specified. Next, consider what actions you would need to take to generate each of these events, and document your plan for doing so. Paste both the configuration steps, and the commands you will execute to test the logging of each event into your lab report.
Execute each of the actions planned in the previous step to generate an event in the audit log.
Determine the location of the audit log (this is commonly /var/lib/mysql/mysql-audit.json). Display the log contents, and analyze them to show that each event you triggered appears in the log. Note: the log file format is not optimized for human readability. The default format generated by this plugin is a .json file, which is easily read and processed for many purposes, including generating pager or system alerts, automated threat responses, as well as reporting. Reporting software that uses such logs is known as Security Information and Event Management (SIEM) software. You may also find utilities that will read and format .json file format into a layout that is easier for humans to read. In any event, take screen shots of your log results, and annotate them to show that each of the required events was captured by the log. Paste a copy of this result into your lab report.
CHECKPOINT QUESTION: What has been achieved by this lab, and what steps would remain to provide a comprehensive security system, including reporting, monitoring, alerting, and Automated Threat Response (automatic countermeasures)? In your answer, give an example of a specific example of each of these, and discuss how it would operate (e.g., an Automated Threat Response might be to disable a user account, or to dynamically add a firewall rule rejecting any further traffic from a specific host computer from which a prohibited event was generated). Record your answer in the lab report.
Laboratory Report DeVry University College of Engineering and Information Sciences
Course Number: DBM449
Laboratory Number: 5
Laboratory Title: Database Security
Note: There is no limit on how much information you will enter under the three topics below. It is important to be clear and complete with your comments. Like a scientist you are documenting your progress in this week’s lab experiment.
Objectives: (In your own words what was this lab designed to accomplish? What was its purpose?)
Results: (Discuss the steps you used to complete your lab. Were you successful? What did you learn? What were the results? Explain what you did to accomplish each step. You can include screen shots, code listings, and so on. to clearly explain what you did. Be sure to record all results specifically directed by the lab procedure. Number all results to reflect the procedure number to which they correspond.)
Conclusions: (After completing this lab, in your own words, what conclusions can you draw from this experience?)
0 notes
Text
Follow Below Link to Download Tutorial
https://homeworklance.com/downloads/dbm-449-devry-ilab-5-assignment/
For More Information Visit Our Website ( https://homeworklance.com/ )
Email us At: [email protected] or [email protected]
Laboratory Procedures DeVry University College of Engineering and Information Sciences
I. OBJECTIVES
Understand and become familiar with fundamentals of DBMS security monitoring, auditing, logging, alerting, and reporting.
Install and configure a MySQL database.
Install and configure an Audit and Security module for MySQL database.
Generate logged events, and inspect contents of an Audit Log.
II. PARTS LIST
EDUPE-VT Omnymbus Virtual Machine Environment (https://devry.edupe.net:9090/) and/or:
MySQL (dev.mysql.com/downloads)
III. PROCEDURE, Part A—Installing MySQL
In order to complete this lab, you will require full control over a LINUX host operating system into which you will install and configure the MySQL database engine. You may achieve this through the DeVry iLab environment (https://devry.edupe.net:9090/), or by installing MySQL onto your own LINUX-based computer, or even into a LINUX Virtual Machine (VM) running in a VM environment on your own computer, such as VMWARE Player, or Sun’s Virtual Box. Full instructions for installing and configuring your own VM environment are beyond the scope of this lab, so unless you have prior experience with VM’s, using the DeVry iLab or installing onto your own LINUX-based computer is recommended.
Preliminary Configuration (DeVry iLab environment only)
Log into the DeVry Omnymbus EDUPE-VT environment, https://devry.edupe.net:9090/.
Create a single VM, using Template #6: VMX-LINUX-DESKTOP-UBUNTU. While you might presume that you should choose SERVER instead of DESKTOP, the DESKTOP VM image provides many tools running from the Graphical User Interface (GUI), which you may find convenient, especially if your experience in LINUX Operating System environments is limited.
Complete all steps required by Omnymbus to complete the configuration of your LINUX host, such as changing the root password and host name. Make a note of the IP address assigned to your new VM, for future use when managing or using your VM instance.
MySQL Database Installation (all environments)
Install the current release (general, not beta) of MySQL. If you are using UBUNTU LINUX, you may do this from the UBUNTU SOFTWARE CENTER, found under APPLICATIONS on the desktop. For other versions of LINUX, research available methods for downloading and installing MySQL appropriate to your Operating System. These might include APT-GET, RedHat Package Manager (RPM), YUM, and so on.
Configure and test that your MySQL service. Be sure that the services have started, and that you are able to connect to MySQL. This may be done in a terminal session using a command line statement, such as: mysql –host=localhost –user=myname –password mydb. Alternatively, you may choose to download and install a GUI SQL administration tool, such as TORA or MySQL Workbench. The command line is installed by default; the GUI tools are optional.
Take a screenshot of your successful connection to your MySQL database, and paste this into your lab report.
We will need a database later, in order to test the audit logging of events we choose to monitor. Just about any trivial database, with a little bit of data in it will suffice. You may use SQL scripts from previous labs, or use the Internet to search for and obtain a copy of the scripts to create and populate the SAKILA sample database. Choose whatever method and schema you wish, and run the scripts to create and populate some tables. Test your data model briefly by issuing a SELECT * from one of the tables. Paste a screen shot showing the successful SELECT and the first five or six rows of the result into your lab report.
McAfee Audit Module Download and Installation (all environments)
CHECKPOINT QUESTION: In order to proceed with the installation of the McAfee Audit Plugin for MySQL, you will need to gather some additional information. These checkpoint questions will help you to clarify this task: What version of LINUX are you running, and how do you determine this? Are you running a 32-bit or 64-bit version of the Operating system, and how do you determine this? How can you obtain/Where can you download an appropriate version of the McAfee Audit Plugin for your use? Once downloaded, how do you unpack the package to access the plugin components? What is the path of the plugin directory into which you must copy the unpacked/unzipped plugin? Record your answers to these questions, and paste them into your lab report. Download, unpack, and copy all files where they belong. (Hint: If you are unable to find a pre-built installation options through your desktop controls, such as Ubuntu Software Center, you can also download the package using a browser, or by using the wget command line interface statement. This latter statement would begin similar to: sudo wget…)
CHECKPOINT QUESTION: The installation of the plugin is done from within the MySQL console. What is the command you must issue to install the plugin? Record your answer in your lab report.
Issue the MySQL console command to install the plugin.
From the MySQL console, issue the command: show plugins;. Take a screenshot showing your successful results, and paste it into your lab report.
Configuring the McAfee Audit Module (all environments)
CHECKPOINT QUESTION: Even though the McAfee Audit Plugin in now installed, it is not yet monitoring things as we would wish. First, the Plugin must be configured. Research what events the plugin is capable of logging, and how to edit the configuration to log them. What command must be entered or what files edited in order to cause the plugin to log the following events: Connect, Quit, Failed Login, Insert, Drop, Create? Record the exact steps you must take and the commands you must enter in order to begin logging the events specified. Next, consider what actions you would need to take to generate each of these events, and document your plan for doing so. Paste both the configuration steps, and the commands you will execute to test the logging of each event into your lab report.
Execute each of the actions planned in the previous step to generate an event in the audit log.
Determine the location of the audit log (this is commonly /var/lib/mysql/mysql-audit.json). Display the log contents, and analyze them to show that each event you triggered appears in the log. Note: the log file format is not optimized for human readability. The default format generated by this plugin is a .json file, which is easily read and processed for many purposes, including generating pager or system alerts, automated threat responses, as well as reporting. Reporting software that uses such logs is known as Security Information and Event Management (SIEM) software. You may also find utilities that will read and format .json file format into a layout that is easier for humans to read. In any event, take screen shots of your log results, and annotate them to show that each of the required events was captured by the log. Paste a copy of this result into your lab report.
CHECKPOINT QUESTION: What has been achieved by this lab, and what steps would remain to provide a comprehensive security system, including reporting, monitoring, alerting, and Automated Threat Response (automatic countermeasures)? In your answer, give an example of a specific example of each of these, and discuss how it would operate (e.g., an Automated Threat Response might be to disable a user account, or to dynamically add a firewall rule rejecting any further traffic from a specific host computer from which a prohibited event was generated). Record your answer in the lab report.
Laboratory Report DeVry University College of Engineering and Information Sciences
Course Number: DBM449
Laboratory Number: 5
Laboratory Title: Database Security
Note: There is no limit on how much information you will enter under the three topics below. It is important to be clear and complete with your comments. Like a scientist you are documenting your progress in this week’s lab experiment.
Objectives: (In your own words what was this lab designed to accomplish? What was its purpose?)
Results: (Discuss the steps you used to complete your lab. Were you successful? What did you learn? What were the results? Explain what you did to accomplish each step. You can include screen shots, code listings, and so on. to clearly explain what you did. Be sure to record all results specifically directed by the lab procedure. Number all results to reflect the procedure number to which they correspond.)
Conclusions: (After completing this lab, in your own words, what conclusions can you draw from this experience?)
0 notes