| |
Using the OLAP Analytic Workspace
Module Objectives
Purpose
This module focuses on how to build and use an OLAP environment for analytical
reporting and predictive analysis.
Objectives
After completing this module, you should be able to:
Prerequisites
Before starting this module, you should have completed the following:
Reference Material
The following is useful reference material if you want additional information
about the topics in this module:
 |
Documentation: Oracle9i OLAP Developers Guide to the OLAP
DML
|
| |
Documentation: Oracle9i OLAP Developers Guide to the OLAP
API |
| |
Documentation: OLAP User's Guide |
Overview
The Oracle9i
Database is an integrated Relational - Multidimensional database. The
database contains the full power of the Relational engine and Online Analytic
Processing (OLAP) engine. This architecture reduces cost and effort without
compromising performance and analytic power. The diagram below depicts
the architecture of the integrated database.

Generally speaking relational systems offer data management features,
and multidimensional systems offer calculation and analytic features.
The advantages of an integrated Oracle9i
database are:
 |
High availability, scalability and reliability
|
 |
The ability to process complex analytics, forecasts and planning
in the same database system that supports your Business Intelligence
applications.
|
 |
Security for all data in the database, including multidimensional
data.
|
 |
Reduced update time because all of the data is in the same
database system. |
 |
Open access to both relational and multidimensional data.
|
 |
Expanded capabilities of standard reporting tools. Multidimensional
results are presented in a relational format and can be accessed through
existing relational tools and applications. |
| |
Reduced maintenance because all of the data is in the same database
system. |
OLAP Objects in the Oracle9i
Database
The objects and features described in this section play an important
role in OLAP processing. You will need to know how to create, populate
and maintain them in the Oracle9i
integrated database. There are three different ways to create,
populate and maintain these objects:
| 1. |
Manually using SQL, PL/SQL and OLAP DML commands
|
| 2. |
Using Enterprise Manager and Analytic Workspace Manager
|
| 3. |
Using Oracle Warehouse Builder
|
The objects you need to understand are as follows:
| Relational Cube |
Modeled from a Star Schema. It contains a fact table with surrounding
tables that help put the fact data within a context.
|
| Multidimensional Cube |
Fact data is contained within each cell of the cube. The contextual
data runs along the edges. Multidimensional cubes are stored in
an Analytic Workspace (AW). A particular AW can contain more than
one cube.
|
| Analytic Workspace |
A LOB which is a multidimensional data type, and it is stored in
a column in a relational table. Some of the multidimensional objects
in an AW represent metadata and contain metadata values. Other objects
contain multidimensional data values.
|
| Metadata |
Data about data. It contains both logical descriptions and physical
mappings. The logical description of data includes information about
dimensions, levels, hierarchies, attributes and relationships. Mappings
associate the logical descriptions to the physical location of the
data. Metadata information is stored in the OLAP Catalog. The AW
also contains metadata.
|
| A View Over the AW |
To enable SQL access to the data in an AW, you can create
a view using the OLAP_TABLE function in its definition. Once the view
has been created, the data in the AW can be accessed by applications
that generate SQL and by applications that write to the OLAP API |
So, what will you do in this lesson?
In this lesson you will create the OLAP metadata based on the Relational
Cube already defined in the SH schema. You will then create your AW and
then create a view over the AW and select from the view you just created.
Set Up OLAP Environment
You will need to perform the following tasks to set up the OLAP environment:
| 1. |
Edit mksh1.sql and
loadaw.sql to make sure the drive and directories are
set correctly.
|
| 2. |
You will need to create a subset of the SH schema so that you can
practice creating some dimensions and a cube in Enterprise Manager.
Move the scripts mksh1.sql,
sh1_main.sql and sh1_pop3.sql
to your d:\oracle\ora92\demo\schema\sales_history
directory. Open a DOS prompt and execute the following commands:
d:
cd oracle\ora92\demo\schema\sales_history\
set oracle_sid=orcl
sqlplus /nolog
@mksh1
|
| 3. |
You will need to give SH and SH1 the privileges necessary to log
into Enterprise Manager. Execute the following script:
@d:\wkdir\grantpriv
|
| 4. |
You will need to load an analytic workspace so that you can create
a view later in this lesson. Execute the following script:
@d:\wkdir\loadaw
|
Using Enterprise Manager to Create OLAP Metadata Objects
When the database is created, the SH user is created and preconfigured
with the OLAP metadata objects. Since you would like to gain some practice
creating metadata objects using Enterprise Manager, a new SH1 user has
been created without the OLAP metadata. You will create the PRODUCTS and
TIMES dimensions and COSTS cube. Perform the following steps:
Note: Later in this lesson you will switch back to using the SH users
metadata objects when creating a view on the Analytic Workspace since
all the data is already loaded.
Create the PRODUCTS Dimension
Back to List
You will create the PRODUCTS dimension using Enterprise Manager. Perform
the following:
| 1. |
Select Start > Programs > Oracle - OraHome92
> Enterprise Manager Console. Select Launch
Standalone and click OK.

|
| 2. |
Expand your database ORCL.WORLD and login as SH1.
Expand Warehouse then OLAP and right-click on Dimensions.
Select Create using Wizard...

|
| 3. |
At the welcome window, click Next.

|
| 4. |
Make sure Create a dimension object is selected and click
Next.

|
| 5. |
Enter PRODUCTS_DIM for the dimension name, make sure the
SH1 schema is selected from the list and click Next.

|
| 6. |
Enter the name CATEGORY, make sure the type Normal,
the SH1 Schema, and the Table PRODUCTS are selected.
Select the PROD_CATEGORY column from the Available Columns
list and click > to move it to the Select Columns list
and click the New button.

|
| 7. |
Enter the name PRODUCT, make sure the type Normal,
the SH1 Schema, and the Table PRODUCTS are selected.
Select the PROD_ID column from the Available Columns list
and click > to move it to the Select Columns list and
click the New button.

|
| 8. |
Enter the name SUBCATEGORY, make sure the type Normal,
the SH1 Schema, and the Table PRODUCTS are selected.
Select the PROD_SUBCATEGORY column from the Available Columns
list and click > to move it to the Select Columns list
and click Next.

|
| 9. |
Click Next.

|
| 10. |
You will now define the hierarchies for your dimension. Click New.

|
| 11. |
Enter the Name PROD_ROLLUP. Then select CATEGORY
and click > to move it to the Selected Levels list, then
select SUCATEGORY and click >. Notice that it is
a sublevel of CATEGORY. Then select PRODUCT then >.
Then click Next.

|
| 12. |
Click Next.

|
| 13. |
Click Finish to create the dimension.

|
| 14. |
Click OK.

|
Create the TIMES Dimension
Back to List
Now you will create the TIMES dimension. Perform the following:
| 1. |
Right-click again on Dimensions and select Create using
Wizard...

|
| 2. |
At the welcome window, click Next.

|
| 3. |
Select Create a Time dimension object and click Next.

|
| 4. |
Enter TIMES_DIM for the dimension name, select the SH1
schema from the list and click Next.

|
| 5. |
Select the Year level. Make sure the SH1 schema,
and the TIMES table are selected. Select the CALENDAR_YEAR
from the Available Columns list and click > to move it
to the Selected Columns list. Then select the Quarter level.

|
| 6. |
With the Quarter level selected, make sure the SH1
schema, and the TIMES table are selected. Select the CALENDAR_QUARTER_DESC
from the Available Columns list and click > to move it
to the Selected Columns list. Then select the Month level.

|
| 7. |
With the Month level selected, make sure the SH1
schema, and the TIMES table are selected. Select the CALENDAR_MONTH_DESC
from the Available Columns list and click > to move it
to the Selected Columns list. Then select the Day level.

|
| 8. |
With the Day level selected, make sure the SH1 schema,
and the TIMES table are selected. Select the TIME_ID
from the Available Columns list and click > to move it
to the Selected Columns list. Then click New.

|
| 9. |
Enter the name FIS_MONTH, make sure the SH1 schema,
and the TIMES table are selected. Select the FISCAL_MONTH_DESC
from the Available Columns list and click > to move it
to the Selected Columns list. Then click New.

|
| 10. |
Enter the name FIS_QUARTER, make sure the SH1 schema,
and the TIMES table are selected. Select the FISCAL_QUARTER_DESC
from the Available Columns list and click > to move it
to the Selected Columns list. Then click New.

|
| 11. |
Enter the name FIS_WEEK, make sure the SH1 schema,
and the TIMES table are selected. Select the WEEK_ENDING_DAY
from the Available Columns list and click > to move it
to the Selected Columns list. Then click New.

|
| 12. |
Enter the name FIS_YEAR, make sure the SH1 schema,
and the TIMES table are selected. Select the FISCAL_YEAR
from the Available Columns list and click > to move it
to the Selected Columns list. Then click Next.

|
| 13. |
At the Define Attributes window, select Long_Description,
select FIS_MONTH from the list of Select Levels and click
< to deselect it. Do the same for FIS_WEEK and
Year. Then select Short_Description.

|
| 14. |
Deselect FIS_WEEK, FIS_YEAR and Year from
the list of Select Levels and click < to deselect them.
Then click Next.

|
| 15. |
At the Define Hierarchies window, select Calendar and change the
name to CAL_ROLLUP. Select Year from the list of Available
Levels and click > to select it. Then select Quarter,
Month and Day and select them. Then select the Fiscal
hierarchy.

|
| 16. |
Change the name to FIS_ROLLUP and select the following levels
in the following order: FIS_YEAR, FIS_QUARTER, FIS_MONTH,
FIS_WEEK, Day. Then click Next.

|
| 17. |
Click Next.

|
| 18. |
Click Finish to create the TIMES dimension.

|
| 19. |
Click OK.

|
Create the COSTS Cube
Back to List
And finally you will create a COSTS cube. Perform the following:
| 1. |
Right-click on Cubes and select Create using Wizard...

|
| 2. |
At the welcome window, click Next.

|
| 3. |
Enter the name COST_CUBE, a display name of Cost Analysis,
select the SH1 schema and enter the description Unit Cost,
Unit Price <TIMES PRODUCTS> then click Next.

|
| 4. |
You will need to select a Fact table. Expand SH1 then select
COSTS and click > to move it to the Select table
list and click Next.

|
| 5. |
Shift-select the PRODUCTS_DIM and TIMES_DIM dimensions
and click > to move them to the selected list and click
Next.

|
| 6. |
With the PRODUCTS_DIM dimension(alias) selected, select
the FKey Col in Fact Table as PROD_ID. Note, select the field
then select the drop down list box and select the column from the
list. Then select the TIMES_DIM dimension.

|
| 7. |
Select the TIME_ID from the drop down list box and click
Next. Note: if your Next button is not active, select PRODUCTS_DIM
again to make sure your FKey Col is PROD_ID. Both must be specified
before the Next button becomes active.

|
| 8. |
At the Specify Measures window, select UNIT_COST and enter
the description Unit Cost Amount, then select UNIT_PRICE.

|
| 9. |
Enter the description Unit Price Amount and click Next.

|
| 10. |
At the Summary screen you can view the SQL. Click Show SQL.

|
| 11. |
This SQL will be executed when you click Finish on the previous
window. Click OK.

|
| 12. |
To see the cube graphically, click Graphical View. Click
OK when you are done reviewing the graphic view.

|
| 13. |
Deselect Launch Summary Advisor Wizard to optimize the cube
and click Finish.

|
| 14. |
Click OK.

|
Create and Populate an Analytic Workspace
An analytic workspace stores multidimensional data objects and procedures
written in the OLAP DML. Within a single database, many analytic workspaces
can be created and shared among users. Like relational tables, an analytic
workspace is owned by a particular user ID, and other users can be granted
access to it. Because individual users can save a personal copy of their
alterations to a workspace, the workspace environment is particularly
conducive to planning applications. An analytic workspace can be temporary
(that is, for the life of the session) or it can be persistent, that is,
saved from one session to the next. When an analytic workspace is persistent,
the data is stored as LOBs in database tables. Analytic workspaces also
provide an alternative to materialized views as a means of storing aggregate
data.
The Analytic Workspace Manager is a GUI interface that can assist you
in viewing and populating an analytic workspace. The Analytic Workspace
Manager will be available in the next release of the database. Click
the Show Me button below to see a glimpse of what it will look like.

Create a View of your Analytic Workspace using the OLAP_TABLE Function
The OLAP_TABLE function extracts data from the LOBs in which your workspace
data has been stored and presents the result set in the format of a relational
table. The OLAP_TABLE function can be used in a SQL SELECT statement instead
of, or in addition to, the names of relational tables and views. It presents
fully solved data that is either stored or calculated in an analytic workspace.
Perform the following steps:
| 1. |
You create an object type, a table on that object type and then
create the COST_BASE_VIEW view itself. From a SQL*Plus session,
execute the following script:
@createview
set serveroutput on connect sh/sh@orcl.world execute DBMS_AW.EXECUTE('AW ATTACH cost_aw RW') execute DBMS_AW.EXECUTE('CDA AW') execute DBMS_AW.EXECUTE('INFILE limitselect.inf') execute DBMS_AW.EXECUTE('UPDATE') execute DBMS_AW.EXECUTE('COMMIT') / DROP view cost_base_view / DROP type cost_base / DROP type cost_base_type / CREATE OR REPLACE TYPE cost_base_type AS OBJECT ( time_id VARCHAR2(20), time_parent VARCHAR2(20), product_id VARCHAR2(40), cost NUMBER) / CREATE OR REPLACE TYPE cost_base AS TABLE OF cost_base_type / CREATE OR REPLACE VIEW cost_base_view AS SELECT * FROM TABLE (OLAP_TABLE ('cost_aw DURATION session', 'cost_BASE', '', 'DIMENSION time_id FROM sh_times_dim WITH HIERARCHY time_parent FROM sh_times_dim_member_parentrel DIMENSION product_id FROM sh_products_dim MEASURE cost FROM sh_cost_cube_unit_cost LOOP sh_cost_cube_composite PREDMLCMD ''limit_select''')) WHERE cost IS NOT NULL
/
COMMIT;

In this case, the DBMS_AW package is used to execute import limitselect.inf
which contains a series of OLAP DML Commands. The selectlimit.inf
file contains the following:
AW ATTACH COST_AW RW
DELETE LIMIT_SELECT
DEFINE LIMIT_SELECT PROGRAM
PROGRAM
limit sh_products_dim to sh_products_dim_member_levelrel 'PRODUCT'
limit sh_times_dim_hierlist to 'CAL_ROLLUP'
limit sh_times_dim to sh_times_dim_member_levelrel 'DAY'
END
Once the view is created with the imbedded table function, it exists
as a persistent SQL object. When a SELECT is issued against the
view, SQL first processes the table function, which executes the
fetch against the AW based on the information contained within it.
In this case you specified that the LIMIT_SELECT program be run
in the AW before the data is retrieved by the OLAP engine and passed
to the SQL engine. Once the data is returned by the table function,
the SQL engine then processes the predicates, and the view is populated
with the results.
|
Access OLAP Data using the View
Now that you have created the view using the OLAP_TABLE function, you
can access the data just like it is a relational table. Perform the following
steps:
| 1. |
From a SQL*Plus session, execute the following script:
@showolapview
set serveroutput on connect sh/sh@orcl.world column product_id format a20 / column time_id format a20 / select time_id, product_id, cost from cost_base_view where product_id = 'PRODUCT.20' and time_parent = 'MONTH.1998-01';

The result of this query shows the cost of a particular product
in January 1998 is $7.80. As you can see, the price did not fluctuate.
|
Module Summary
In this module, you should have learned how to:
Copyright © 2002 Oracle Corporation. All Rights Reserved.
Close Window
|