Assignment 3 Mat Views
Assignment 3 Mat Views
Assignment 3 Mat Views
and/or distribution company. Inventory transactions are frequent and commonplace. The
volume and significance of these transactions make them ideally suited for OLAP via a data
warehouse.
Because inventory management is a common and important yet difficult activity in many
organizations, ERP vendors have developed Enterprise Resource Management (ERP) software to
provide software support. Typically, ERP software provides modules related to Manufacturing,
Distribution/Logistics modules is inventory. The work order, sales, and purchase life cycles
affect the perpetual inventory balance as shown in Figure 1. In addition, inventory transactions
including adjustments, transfers, issues, and reclassifications affect the perpetual inventory
balance.
7/9/2018 Assignment 3 (Materialized Views) Page 2
the perpetual inventory balance. The snowflake schema provides a template that can be
an organization to customize the design to specific requirements. The fact entity type,
entity types. Several dimension entity types are related directly to the Inventory_Fact entity type.
Other dimension entity types such as Item_Cat_Code1 are indirectly related to the
date_dim inventory_fact
Summary_by_Day
DateKey InventoryKey trans_type_dim
Inventory_Transaction
CalDay zip_codes BranchPlantKey TranTypeKey
CalMonth ZipKey CustVendorKey TransDescription
CalQuarter ZipCity DateKey TransTypeCodeId
CalYear ExtCost Inventory_Facility
ZipConcec
DateJulian ZipState ItemMasterKey
DayofWeek ZipWeight Quantity
FicalYear TransTypeKey branch_plant_dim
ZipZip
FiscalPeriod UnitCost BranchPlantKey
defines Related_Address_Book BPName
Part_Number_ BranchPlantId
addr_cat_code1 item _cat_code1 CarryingCost
CompanyKey
AddrCatCodeKey ItemCatCodeKey
CostMethod
cust_vendor_dim AddrCatCodeId ItemCatCodeId
AddrCatDesc ItemCatDesc
CustVendorKey item _m aster_dim
AddrBookId Ow ning_Company
ItemMasterKey
AddrCatCode1 Addr_Code1 Item_Code1 ItemCatCode1
AddrCatCode2 ItemCatCode2
Addr_Code2 Item_Code2
Address ItemDesc com pany_dim
City SecondItemId CompanyKey
Country ShortItemId
addr_cat_code2 item _cat_code2 CompanyId
Name ThirdItemId
AddrCatCodeKey ItemCatCodeKey CompanyName
PrimZip UOM
AddrCatCodeId ItemCatCodeId CurrencyCode
State
AddrCatDesc ItemCatDesc CurrencyDesc
Zip
The ERD representation of the snowflake schema is converted to a table design using the
normal conversion rules. In the conversion process, 1-M relationships convert to foreign keys in
the child tables. Appendix A contains a data dictionary for the table design while Appendix B
contains the CREATE TABLE statements. Denormalization is always a good option to consider
for a snowflake schema implementation. However, the snowflake schema design reflected in
To populate your tables, you can access my tables on the COBCU2 server. You can use the
INSERT … SELECT statement to populate your tables using the data in my tables. Because you
have SELECT access to my tables, you can use my tables instead of your tables for the
assignment details in sections 4 and 5 if you wish. You can access my tables by using my user
name (mmannino) as a prefix to the table names of the inventory data warehouse. For example to
reference the inventory fact table, you should use “mmannino.Inventory_Fact”. For CREATE
7/9/2018 Assignment 3 (Materialized Views) Page 4
DIMENSION statements in section 3, you need to reference your own tables. Thus you will need
to create the inventory data warehouse tables but you do not need to populate them.
3. Create Dimensions
Write Oracle CREATE DIMENSION statements to create the dimensions of the snowflake
schema tables as specified in the following lists. In writing the CREATE DIMENSION
statements, you should use the JOIN KEY clause if the dimension hierarchy contains levels from
more than one table. You should use the DETERMINES clause to provide dimension constraints.
To assist in my grading, please include DROP DIMENSION statements before your CREATE
DIMENSION statements.
Create a dimension for customer vendor data. The dimension should include levels
for the customer vendor key, the vendor city, the vendor state, the vendor zip, the
vendor country, the address category code key of the first address code, and the
address category code key of the second address code. Define hierarchies to show the
relationships between the customer vendor key and the vendor’s location, the
customer vendor key and the first address code, and the customer vendor key and the
second address code. Use the ATTRIBUTE clause to add functional relationships to
columns in the Address Category Code 1 table and the Address Category Code 2
table.
Create a dimension for item master data. The dimension should include levels for the
item master key, the item category 1 code, and the item category 2 code. Define
hierarchies to show relationships between the item master key and the item category 1
code and the item master key and the item category 2 code. Use the ATTRIBUTE
7/9/2018 Assignment 3 (Materialized Views) Page 5
clause to add functional relationships to columns in the item category 1 and item
category 2 tables.
Create a dimension for branch-plant data. The dimension should include levels for
the branch plant key and the company key. Define a hierarchy to show the
relationship between the branch plant key and the company key. Use the
Create a dimension for date data. The dimension should include levels for the date
key, the calendar day, the calendar month, the calendar quarter, the calendar year, and
the day of the week. Define hierarchies to show relationships among the date key, the
calendar day, the calendar month, the calendar quarter, and the calendar year, and
between the date key and the day of the week. Use the ATTRIBUTE clause to add
functional relationships to the Julian date column in the date dimension table.
4. Write Queries
Write Oracle SELECT statements for the following problems. You may need to use the
CUBE and ROLLUP clauses in your SELECT statements. Your SELECT statements should
reference the fact table (Inventory_Fact) along with the dimension tables of the snowflake
schema in Appendix B. Your SELECT statements should not reference the dimensions that you
created in part 3. Use the CUBE and ROLLUP options of the GROUP BY clause where
Write an SQL statement to display the sum of the extended cost and the sum of the quantity. The
results should include data for shipments (transaction type 5) in the year 2005. Summarize the
result by calendar month and Address Category Code 1. The result should include full totals for
every combination of grouped fields.
7/9/2018 Assignment 3 (Materialized Views) Page 6
Write an SQL statement to display the sum of the extended cost and the number of inventory
transactions. The results should include data for shipments (transaction type 5) in the years 2005
and 2006. Summarize the result by calendar year, calendar quarter, and customer name. The
result should include full totals for every combination of grouped fields.
Write an SQL statement to display the sum of the extended cost, the sum of the quantity, and the
number of inventory transactions. The results should include data for adjustments (transaction
type 1). Summarize the result by Second Item Id (i.e. part number). The result should include full
totals for every combination of grouped fields. In addition, sort the result by Second Item Id.
Write an SQL statement to display the sum of the extended cost and the sum of the quantity. The
results should include data for transfers (transaction type 2). Summarize the result by Second
Item Id (i.e. part number) and branch plant name. The result should include partial totals in order
of the grouped fields (second item id and branch plant name). Transfer quantities by design
should sum to zero.
Write an SQL statement to display the sum of the extended cost and the number of inventory
transactions. The results should include data for all transaction types. Summarize the result by
transaction description and company name. The result should include partial totals in order of the
grouped fields (transaction description and company name).
Rewrite queries 1 and 4 without the usage of the CUBE, ROLLUP, or GROUPING SETS
operators of the GROUP BY clause. The rewritten queries should still access the base tables, not
the materialized views specified in section 5. In rewriting the queries, you may use '' (two single
quotes) as the default text value and 0 as the default numeric value.
specifications. After you write the statements, rewrite queries 1 and 2 from Section 4 using the
Both materialized views should contain the sum of the extended cost, the sum of
The first materialized view should include only sales shipment transactions
The second materialized view should include only sales shipment transactions
Neither materialized view should include subtotals that are created by the CUBE
Rewrite queries 1 and 2 using the materialized views in place of the fact table.
Grading
If you follow the instructions, you should receive full credit. Here are my grading
guidelines:
The CREATE DIMENSION statements in Section 3 are worth 30%. Please include
DROP DIMENSION statements in your assignment listing.
In the deduction of points, I will distinguish between major errors such as syntax errors
and missing statements, medium errors such as missing a table in a SELECT statement,
and minor errors such as missing a WHERE condition in a SELECT statement.
7/9/2018 Assignment 3 (Materialized Views) Page 8
Completion
Upload a file containing your Oracle SQL statements to the Digital Drop Box part of the
Blackboard website. Use the following naming scheme for your assignment file:
LastNameFirstNameA3. To facilitate grading, please format your statements neatly. To test your
code, I will execute your SQL statements using the tables in my account on the COBCU2 server.
Please indicate your name and Oracle user name in your document.
7/9/2018 Assignment 3 (Materialized Views) Page 9
This table defines address category codes related to customers/vendors. These codes allow
customers/vendors to be group. Example grouping might be customer type, customer area, etc.
This table defines address category codes related to customers/vendors. These codes allow
customers/vendors to be group. Example grouping might be customer type, customer area, etc.
This table defines item master category codes related to item masters (parts) These codes allow
part numbers to be group. Example grouping might be product class, spare part, finish good, etc.
This table defines item master category codes related to item masters (parts) These codes allow
part numbers to be group. Example grouping might be product class, spare part, finish good, etc.
This table provides the basis to create many unique customer records for a variety with a variety
of zip codes.
This table provides the date pattern. Date patterns can be daily, five days per week, weekly or
monthly.
This table defines the various types of inventory transactions. Examples include transfers,
adjustments, shipments, receipts, etc.
This table defines possible customers and vendors involved with related sales and purchasing
related transactions.
This table contains the inventory transactions facts. Integer keys are used to help limit the size of
the rows. The measures are unit cost, quantity, and extended cost.