Comp11013 Technologies For Business Intelligence: Coursework # 2

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

COMP11013 TECHNOLOGIES FOR BUSINESS

INTELLIGENCE

Coursework # 2

Name: Muhammad Farooq


Banner ID: B00735313
Assignment: CW2
1. The Star or Snowflake schema for your Global Sales data mart in a diagram, which can
be a screenshot of the ‘database diagram’ of your Global Sales data mart, and an
associated description including that about ‘surrogate keys’ (see step 1 earlier)

DimReturns is the Returns Dimension which shows the list of Returned Items in the Global
Region they are from with Order ID as the Surrogate Key
DimPeople is the Returns Dimension which shows the list of Persons in the Global Region
with Region as the Surrogate Key
DimCustomer is the Customer Dimension which lists the Customers in the Global Superstore
and uses Customer ID as the Surrogate Key
DimProduct is the Product Dimension that lists the Products in the Global Superstore and
uses Product ID as the Surrogate Key
DimOrder is the Order Dimension that lists the Orders in the Global Superstore and the
Order Date and uses Order ID as the Surrogate key
FactTable is the Table that stores the history of Transactions in the Global Superstore and
uses Row ID as the Surrogate Key

2. The relational schema for your Global Sales data mart including PKs, FKs, and ad-hoc
constraints
DimOrder {Order ID, Order Date}
Primary key: Order ID
DimCustomer {Customer ID, Customer Name, Segment}
Primary key: Customer ID
DimProduct {Product ID, Product Name, Category, SubCategory}
Primary key: Product ID
DimReturns {Order ID, Returned, Region}
Primary key: Order ID
Foreign key: Order ID references DimOrder (Order ID)
ALTER TABLE DimReturns
ADD CONSTRAINT FK_ReturnsORder
FOREIGN KEY (Order ID) REFERENCES DimOrder (Order
ID);

DimPeople {Region, Person}


Primary key: Region
FactTable {Row ID, Order ID, Product ID, Customer ID, City, Region,
Country, State, Market, Ship Date, Order Priority, Sales, Quantity, Discount,
Profit, Ship Mode}
Primary key: Row ID
Foreign key: Order ID references DimOrder (Order ID)
Product ID references DimProduct (Product ID)
Customer ID references DimOrder (Customer ID)

ALTER TABLE FactTable


ADD CONSTRAINT FK_FactTableCustomer
FOREIGN KEY (Customer ID) REFERENCES DimCustomer (Customer ID);
ALTER TABLE FactTable
ADD CONSTRAINT FK_FactTableProduct
FOREIGN KEY (Product ID) REFERENCES DimProduct ((Product ID);
ALTER TABLE FactTable
ADD CONSTRAINT FK_FactTableOrder
FOREIGN KEY (Order ID) REFERENCES DimOrder (Order ID);

3. The name of your Global Sales data mart, -


B00735313_B00733467_GlobalSalesDataMart
4. The SQL statements (for which you may use relevant screenshots) for creating all the
tables with data values for your data mart within the ‘Datamart’ schema

5. A screenshot of the list of tables in your Global Sales data mart

6. A screenshot of the content of the fact table and one of the dimensional tables in your
Global Sales data mart
Fact Table

Dimension Table
7. The SQL statements for the OLAP queries specified above and a screenshot for the result
of each of the queries

CUBE
Basically, this query computes the union of 2² = 4 groupings of the FactTable being:
{(CustomerID,Discount), (CustomerID), (Discount), ()}, where () denotes an empty group
list representing the total aggregate across the entire FactTable
DICING
The sample query selects conditions on the ProductID and SUM of the SALES as
TotalSalesForSameDayShipModeinBangkok column WHERE the City Name is Bangkok
and Ship Mode is ’Same Day‘ aggregates them using the ProductID
RANKING
This query returns the rank of each row within the partition of a result set(Sales Column)
where the city is ‘Bangkok’. The rank of a row is one plus the number of ranks that come
before the row in question. The result set is Ordered by ProductID
ROLLUP
This query generates the union of three groupings {(CustomerID,Discount), (CustomerID),
()}, where () again represents the full aggregation
SLICING
The sample query selects conditions on the ProductID and SUM of the SALES column WHERE
the City Name is ‘Mexico City’ and aggregates them using the ProductID
WINDOWING
The example above selects the RowID, ProductID, CustomerID, City, Sales, namely it
aggregates the data for each city and shows the sum of the total sales for each of them

You might also like