11
EXPERIMENT NO 3 AIM: To design and implement data warehouse for a mall management system. THEORY: In computing, a data warehouse (DW or DWH), also known as an enterprise data warehouse (EDW), is a system used for reporting and data analysis. DWs are central repositories of integrated data from one or more disparate sources. They store current and historical data and are used for creating analytical reports for knowledge workers throughout the enterprise. Examples of reports could range from annual and quarterly comparisons and trends to detailed daily sales analyses. The data stored in the warehouse is uploaded from the operational systems (such as marketing, sales, etc., shown in the figure to the right). The data may pass through an operational data store for additional operations before it is used in the DW for reporting.

Experiment No 3 Dwtt

Embed Size (px)

DESCRIPTION

v

Citation preview

Page 1: Experiment No 3 Dwtt

EXPERIMENT NO 3

AIM: To design and implement data warehouse for a mall management system.

THEORY:

In computing, a data warehouse (DW or DWH), also known as an enterprise data

warehouse (EDW), is a system used for reporting and data analysis. DWs are central

repositories of integrated data from one or more disparate sources. They store current and

historical data and are used for creating analytical reports for knowledge workers throughout

the enterprise. Examples of reports could range from annual and quarterly comparisons and

trends to detailed daily sales analyses.

The data stored in the warehouse is uploaded from the operational systems (such as marketing,

sales, etc., shown in the figure to the right). The data may pass through an operational data

store for additional operations before it is used in the DW for reporting.

DATAWAREHOUSE OVERVIEW

Page 2: Experiment No 3 Dwtt

Benefits of a data warehouse are:

A data warehouse maintains a copy of information from the source transaction systems. This

architectural complexity provides the opportunity to:

Congregate data from multiple sources into a single database so a single query engine can

be used to present data.

Mitigate the problem of database isolation level lock contention in transaction processing

systems caused by attempts to run large, long running, analysis queries in transaction

processing databases.

Maintain data history, even if the source transaction systems do not.

Integrate data from multiple source systems, enabling a central view across the enterprise.

This benefit is always valuable, but particularly so when the organization has grown by

merger.

Improve data quality, by providing consistent codes and descriptions, flagging or even fixing

bad data.

Present the organization's information consistently.

Provide a single common data model for all data of interest regardless of the data's source.

Restructure the data so that it makes sense to the business users.

Restructure the data so that it delivers excellent query performance, even for complex

analytic queries, without impacting the operational systems.

Add value to operational business applications, notably customer relationship

management (CRM) systems.

Make decision–support queries easier to write.

Dimension and Fact Tables:

Data warehouses are built using dimensional data models which consist of fact and dimension tables. Dimension tables are used to describe dimensions; they contain dimension keys, values and attributes. For example, the time dimension would contain every hour, day, week, month, quarter and year that has occurred since you started your business operations. Product dimension could contain a name and description of products you sell, their unit price, color, weight and other attributes as applicable. Dimension tables are typically small, ranging from a few to several thousand rows. Occasionally dimensions can grow fairly large, however. For example, a large credit card company could have a customer dimension with millions of rows.

Page 3: Experiment No 3 Dwtt

Fact tables contain keys to dimension tables as well as measurable facts that data analysts would want to examine. For example, a store selling automotive parts might have a fact table recording a sale of each item. The fact table of an educational entity could track credit hours awarded to students. A bakery could have a fact table that records manufacturing of various baked goods. Fact tables can grow very large, with millions or even billions of rows.

IMPLEMENTATION:

Fact and Dimension Tables:

In the mall management system project, the dimensions considered in the Fact Table Sales are order_id, prod_id, id, branch_id, brand_id,time_id and shop_id. The star schema is constructed using the following Dimension Tables.

DimProduct

DimOrder

DimShop

DimCustomer

DimBranch

DimBrand

DimTime

CREATE TABLE `DimBranch` (`branch_id` mediumint primary key,`location` varchar(255),

`branch_sales` mediumint default NULL

); CREATE TABLE `DimOrder` ( `order_id` mediumint primary key, `no_of_items` mediumint default NULL, `amount_paid` mediumint default NULL

Page 4: Experiment No 3 Dwtt

);CREATE TABLE `DimCustomer` ( `id` mediumint primary key, `name` varchar(255) default NULL, `address` varchar(255) default NULL, `redeem_points` mediumint default NULL, `email_id` varchar(255) default NULL);CREATE TABLE `DimProduct` ( `prod_id` mediumint primary key, `description` TEXT default NULL, `price` mediumint default NULL);

CREATE TABLE `DimTime` ( `time_id` mediumint primary key, `month` varchar(255), `year` varchar(255), `date` DATE);CREATE TABLE `DimBrand` ( `brand_id` mediumint primary key, `sales` mediumint default NULL, `brand_name` varchar(255) default NULL );CREATE TABLE `DimShop` ( `shop_id` mediumint primary key, `total_sales` mediumint default NULL, `name` varchar(255) default NULL );

CREATE TABLE `FactSales` ( `time_id` mediumint, `id` mediumint, `order_id` mediumint, `branch_id` mediumint, `brand_id` mediumint, `prod_id` mediumint, `shop_id` mediumint,constraint `am1` foreign key (`time_id`) references `DimTime`(`time_id`),constraint `am2` foreign key (`id`) references `DimCustomer`(`id`),constraint `am3` foreign key (`order_id`) references `DimOrder`(`order_id`),constraint `am4` foreign key (`branch_id`) references `DimBranch`(` branch _id`),constraint `am5` foreign key (`prod_id`) references `DimProd`(`prod_id`),constraint `am6` foreign key (`shop_id`) references `DimShop`(`shop_id`), constraint `am7` foreign key (`brand_id`) references `DimBrand`(`brand_id`));

Page 5: Experiment No 3 Dwtt

1. LOAD DIMENSION TABLE

Loading the table is done using INSERT Command as INSERT INTO `dwh`.`dimbranch` (`branch_id`, `location`, `branch_sales`) VALUES ('1', 'Ghatkopar', '50000'), ('2', 'Thane', '40000'), ('3', 'Lower Parel', '45000'), ('4', 'Grant Road', '35000'), ('5', 'Koregaon Park', '70000'), ('6', 'Mulund', '60000'), ('7', 'Dadar', '34000'), ('8', 'Bandra', '67000'), ('9', 'Nagpur', '56000'), ('10', 'Versova', '29000'), ('11', 'Chembur', '43000'), ('12', 'Andheri', '69000'), ('13', 'Juhu', '49000'), ('14', 'Vashi', '23000'), ('15', 'Santacruz', '54000');

4. LOAD FACT TABLELoading the table is done using INSERT Command as :INSERT INTO `dwh`.`factsales` (`shop_id`, `id`, `branch_id`, `brand_id`, `order_id`, `time_id`, `prod_id`) VALUES ('1', '1', '2', '3', '1', '2', '1'), ('2', '14', '10', '2', '7', '1', '3'), ('3', '1', '2', '3', '4', '7', '9'), ('1', '2', '14', '4', '16', '7', '4'), ('2', '14', '4', '3', '19', '2', '7'), ('2', '3', '5', '9', '11', '3', '9'), ('6', '4', '3', '5', '18', '5', '2'), ('3', '8', '5', '2', '18', '5', '8'), ('4', '15', '11', '1', '17', '8', '8'), ('3', '5', '10', '7', '17', '3', '5'), ('2', '5', '1', '8', '19', '2', '3'), ('3', '3', '4', '7', '5', '9', '3'), ('4', '14', '15', '8', '15', '7', '6'), ('2', '3', '3', '2', '16', '3', '8'), ('1', '2', '13', '2', '17', '9', '9'), ('3', '7', '2', '1', '18', '2', '8'), ('3', '3', '1', '6', '17', '9', '7'), ('4', '1', '1', '2', '13', '7', '5'), ('5', '2', '4', '2', '4', '5', '1'), ('6', '5', '2', '4', '15', '5', '1');

EXECUTE QUERYselect * from DimOrder;

select * from DimBranch;

Page 6: Experiment No 3 Dwtt

select * from DimShop;

select * from DimCustomer;

Page 7: Experiment No 3 Dwtt

select * from DimBrand;

select * from DimTime;

Page 8: Experiment No 3 Dwtt

select * from DimProduct;

select * from FactSales

Page 9: Experiment No 3 Dwtt

CONCLUSION:

In this experiment we studied the implementation and design of a data warehouse by creation of Fact and Dimension tables.