Вы находитесь на странице: 1из 43

Warehouse Builder

Dimensional Design

Dimensional Design

Dimensional Design with Oracle Warehouse Builder


Purpose
In this excercise you will create a datamodel in dimensional form supports a sales order cube.

Topics
This excercise covers the following topics: Prerequisites Introduce the OE system as source Design of the dimensional data Model APPENDIX Using OWB for Dimensional Design

Prerequisites
The 1. module Also it is a good idea to read the APPENDIX Using OWB for Dimensional Design at the end of this exercise.

Design of the dimensional data Model


Create a cube structure that handles a sales cube. The stucture must be based on a dimensional design. Step 1 Create a new project for your Datawarehouse project Create a new module OE that is a source module In the location the username/password for the user is oe/oe. Import the following tables : order_items, customer, products, employees. Hint : Make sure you have One level set.

Page 1 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

Step 2 Customer X has asked you to design a new BI system for them, that can handle the reporting of sales orders over time. Therefor you have conducted a set of interviews with different representatives from customer X too find out which needs customer X has regarding their reporting. Based on these interviews, you have identified certain needs in connection with the desired reports. And you have identified that as a minimum the following attributes must be present in the cube : Customer number Address Delivery date City Created date Order number Payment date Item number Units Price per item Item text Customer name Zip Code Salesperson Department Sales persons name (first and last) It is up to you to find good find names (eihter in Danish or English) for the datamodel. Also you should asure that all attributes you would like in the datamodel is present. Hint 1 : Your cube should as a minimum consist of 4 dimensions and 1 cube Hint 2 : REMEMBER that normalization is NOT ALLOWED !!!!! Hint 3 : Look at the source system

Step 3

Create a new Oracle Module for the DW. Use your username in the location settings. Create dimensions and cube(s) necessary for your datamodel. Asure that each dimension has a good set of levels and hierachies.

Page 2 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

Step 4 When the design is finished deploy it to your datawarehouse.

Page 3 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

APPENDIX Using OWB for Dimensional Design


Overview
Oracle Warehouse Builder provides advanced relational and dimensional modeling capabilities. It enables you to create definitions for relational objects such as Tables, Views, Materialized Views, Sequences, and External Tables and dimensional target objects such as Dimensions and Cubes. Oracle Warehouse Builder explicitly separates dimensional design from physical implementation. You can choose either a relational implementation or a multidimensional implementation for the dimensional objects using a simple click operation. Therefore, the same dimensional object design can be implemented as a relational target warehouse or a multidimensional (implemented in OLAP) warehouse. In this lesson, you design a dimensional model implemented as a relational target warehouse. For relational modeling, Warehouse Builder supports the design and implementation of both Star and Snowflake schemas. You also model a simple star schema consisting of a cube with foreign key references to two dimensions.

Defining a Target Warehouse Module


To begin designing the model of your target warehouse, you can start by defining a target module. Target modules contain the metadata definition of the target objects you design. Every target module must be mapped to a target user schema. Therefore, before you create a Warehouse Builder target module, you need to create a target schema that will physically store your target objects on deployment. Then, you make sure that the target module references this target schema by assigning an appropriate location. Create a Target Module
1.

In the your project, expand the Databases node, right-click the Oracle node, and select New.

Page 4 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

The Create Module Wizard is launched. Click Next on the Welcome page.
2.

On the Name and description page, enter YOUR DW NAME as the name of the module. Accept Development as the module status and ensure that Warehouse Target is selected as the module type. Click Next.

Page 5 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

3.

On the Connection information page, from the Location drop-down , select YOUR DW NAME_LOCATION as the location of the module. Observe that all the relevant connection details are already specified. This is because Warehouse Builder derives the location information directly from the user you created. Click Next. Note: Before you selected YOUR DW NAME_LOCATION from the Location dropdown , YOUR DW NAME_LOCATION1 was selected by default. This is because whenever you try to create a module, Warehouse Builder automatically assigns a location with _LOCATION<no> suffixed to the module name. You have selected the location, YOUR DW NAME_LOCATION, which was created when you created the YOUR DW NAME target user.

Page 6 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

On the Summary page, examine the details and click Finish.


4.

Observe that the YOUR DW NAME target module has been added under the Oracle node of the YOUR PROJECT project. Expand YOUR DW NAME and examine its contents.

Page 7 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

Until now, you have created an empty target module YOUR DW NAME that maps to an empty target schema YOUR DW NAME. Now, you start designing your target objects in this target module.

Designing Dimensions
Dimensions are the primary organizational unit of data in a star schema. Examples of some commonly used dimensions are Customer, Product, and Time. A dimension consists of a set of levels and a set of hierarchies defined using these levels. Users often analyze data by drilling down on known dimension hierarchies. The query performance is improved because the query optimizer makes smart decisions about choosing what data to use. To create a dimension, you must define the following:
Dimension Attributes

Page 8 of 43

Warehouse Builder

Dimensional Design

Dimensional Design
Levels Level Attributes Hierarchies

This topic introduces you to a basic example of a dimension. Before creating dimensions, you examine an existing one to understand the basic design of a dimension. Let us examine a fictive PRODUCTS dimension for its dimension attributes, levels, and hierarchies.
1.

In the Project Explorer panel, you would expand YOUR PROJECT > Databases > Oracle. Expand YOUR DW, and then expand Dimensions. Right-click PRODUCTS and select Open Editor. Note: Alternatively, you can also double-click PRODUCTS.

The Data Object Editor is launched. The Data Object Editor is the single interface where you can easily design, create, and manage a variety of database or dimensional objects. The Data Object Editor is a central place where you can build or modify various warehouse schema designs through the use of diagrams and property sheets. This is how the interface looks:

Page 9 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

As you observe there are numerous panels, but you focus on the Dimensions Details panel to understand the details of a dimension.
2.

To view the dimension's attributes, click the Attributes tab in the Dimension Details panel. Observe that the dimension is assigned a sequence, PROD_DIM_SEQ, to populate a dimension key when loading data. Also, note that one of the attribute ID has been identified as a Surrogate identifier and SOURCE_ID attribute is assigned as the Business identifier.

Page 10 of 43

Warehouse Builder

Dimensional Design

Dimensional Design
Note: The dimension key column is the primary key for the dimension and implements the surrogate identifier of each level. Using a sequence, you can populate the dimension key with unique values. A surrogate identifier uniquely identifies each level record across all the levels of the dimension and is loaded from a sequence, as specified in the dimension key field. A business identifier is an attribute that is always derived from the natural key of the data source. A parent identifier is also available when you want to use value-based hierarchies. In the Descriptor column, the dimension attributes marked as Long Description and Short Description are the ones used to display the dimension members in BI Beans. Click in the Name column and add two DATE attributes, VALID_FROM_DATE and VALID_TO_DATE, with the following details, as shown in the screenshot.

3.

To view the dimension levels and level attributes, click the Levels tab in the Dimension Details panel. Observe that there are four levels and each level has an applicable set of attributes, for example PRODUCT level implements all the dimension attributes as level attributes, except the two date attributes that you added in the previous step. To include the two date attributes as applicable attributes for the PRODUCT level, select the Applicable check boxes for VALID_FROM_DATE and VALID_TO_DATE attributes, as shown in the screenshot.

Page 11 of 43

Warehouse Builder

Dimensional Design

Dimensional Design
Note: A level is not required to implement all dimension attributes. Implementing a dimension attribute on a level enables you to store this information on a level. In a relational implementation, a level attribute becomes a column in a table. Level attributes do not have to have the same name as the dimension attribute, but Warehouse Builder defaults it as such in the panel. When defining the levels you need not worry about the order in which you enter the levels. The levels are only organized in the hierarchies.

4.

To view the dimension hierarchy, click the Hierarchies tab in the Dimension Details panel. Observe that there is only one hierarchy, PROD_STD, with levels arranged in a particular order (top down in the panel ). The Default check box allows you to select a hierarchy that will display when a user queries. So it is important to pick the most commonly used hierarchy for this.

Page 12 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

5.

When you define a dimension, you can also specify the slowly changing dimension strategy. Slowly Changing Dimensions determine how you store historical changes to your dimension values. You can choose between the three strategies, as shown in the screenshot. Click the SCD tab to view the slowly changing dimension strategy for the PRODUCTS dimension.

If you want to store the complete change history, you would use a type 2 implementation. Select Type2: Store the complete change history. Notice that the Settings button is enabled. Click Settings. Page 13 of 43

Warehouse Builder

Dimensional Design

Dimensional Design
In the Type 2 slowly changing policy dialog box, in the Record History drop-down , you need to specify the attributes as:
Trigger History: Select this option for an attribute if a change in the attribute's data element requires the record to create a new version of itself. Effective Date: Set this option for the single attribute if it stores the value of the date/time the record becomes active. Expiration Date: Set this option for the single attribute that stores the date/time the record is no longer valid or effective.

For example, to record the change history whenever the _PRICE, NAME and PACK SIZE of a product changes, set them as Trigger History attributes, as shown in the screenshot. Also, VALID_FROM_DATE is set as Effective Date and VALID_TO_DATE is set as Expiration Date attributes.

Click Close in the Type 2 slowly changing policy dialog box.

Page 14 of 43

Warehouse Builder

Dimensional Design

Dimensional Design
6.

You design dimensional objects using Warehouse Builder, and then deploy them either in a relational form or in a multidimensional form to the database. On the Storage tabbed page, you decide whether the designed dimension is implemented as relational or multidimensional and based on the type, Warehouse Builder generates appropriate storage type code. Click the Storage tab to view the selected implementation for the PRODUCTS dimension. For a relational implementation, you can choose between Star, Snowflake, or Manual.

The Data Object Editor also provides a Data Viewer that enables you to view and drill down into a dimension's data. From the Diagram menu, select Close Window to exit the Data Object Editor. In the following steps, you create two simple dimensions related to the Expenses scenario. You could create the dimensions in the Data Object Editor, but in this lesson you use wizards to create dimensions. This gives you a set of defaults and enables you to create a dimension with a set of easy-to-understand steps.

Create REL_TIME Dimension Using the TIME Dimension Wizard


Time dimensions are used extensively in data warehouses to address time series, such as queries (for example: What is the expense for the quarter as compared to last year's quarter?). A time dimension also consists of a set of levels and a set of hierarchies defined over these levels. You can use Warehouse Builder to create both fiscal and calendar time dimensions. Page 15 of 43

Warehouse Builder

Dimensional Design

Dimensional Design
Warehouse Builder enables you to not only create but also populate time dimensions. When you create a time dimension using the wizard, Warehouse Builder automatically creates the mapping for you to populate the time dimension. Also, the data loaded into the time dimension conforms to the OLAP standards regarding attributes for a time dimension. Now, you perform the steps to create the REL_TIME dimension using the Time Dimension Wizard.
1.

You were previously examining the YOUR DW module. Now, expand YOUR DW NAME, right-click Dimensions and select New > Using Time Wizard.

The Create Time Dimension Wizard is launched. Click Next on the Welcome Page.
2.

Page 16 of 43

Warehouse Builder

Dimensional Design

Dimensional Design
On the Name and Description page, enter REL_TIME as the name of the dimension. Click Next.

3.

On the Storage page, select Relational Storage (ROLAP) to specify relational implementation of the dimension. Click Next.

Page 17 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

4.

On the Data Generation page, you specify the range of time data that is required for your warehouse. This information is used to generate a mapping that populates the time dimension. Within this mapping, the dates you enter are added as parameters, allowing you to rerun this mapping with dates at a later stage. For Start Year, enter 2003 and for Number of Years enter 3. Ensure that Calendar is selected, as shown in the screenshot. Note: A hierarchy defines hierarchical relationships between adjacent levels in a time dimension. A time dimension can have one or more hierarchies. Each hierarchy must be either a fiscal hierarchy or a calendar hierarchy. If your time dimension contains fiscal data, you must specify the start month and day for the fiscal year and start day for the fiscal week. You also need to specify month and quarter boundary convention that can be 445 or 544. Page 18 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

5.

On the Levels page, select Normal Hierarchy and select all the levels: Calendar Year, Calendar Quarter, Calendar Month and Day. Click Next.

Page 19 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

6.

On the Pre Create settings page, examine the details and click Next.

Page 20 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

A progress bar shows the progress as the wizard creates the necessary objects.

Page 21 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

On successful completion, click Next. On the Summary page, examine the details again and click Finish. Observe that the wizard has generated four objects necessary for a fully functional TIME dimension: REL_TIME dimension object, REL_TIME_SEQ sequence that populates the surrogate ID of the time dimension levels, REL_TIME table to support the relational implementation of the time dimension that physically stores the time data, and most importantly the REL_TIME_MAP mapping to populate the time dimension.

Page 22 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

If you are curious to know how REL_TIME_MAP looks like, double-click REL_TIME_MAP under the Mappings node to launch the Mapping Editor. From the View menu, select Auto Layout. You can see the expanded mapping. You can scroll or select the zoom options from the View menu to view the mapping appropriately. Warehouse Builder creates this complex mapping automatically for you, there by enhancing the productivity and saving your time.

From the Mapping menu, select Close to exit the Mapping Editor. You have finished creating the REL_TIME dimension. Next, you will create REL_CATEGORY dimension using the wizard.

Create the REL_CATEGORY Dimension Using the Wizard


1.

In the YOUR DW NAME module, right-click Dimensions and select New > Using Wizard. Page 23 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

The Create Dimension Wizard is launched. Click Next on the Welcome Page.
2.

On the Name and Description page, enter REL_CATEGORY as the name of the dimension. Click Next.

Page 24 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

3.

On the Storage Type page, select Relational Storage (ROLAP) to specify the relational implementation of the dimension. Click Next.

Page 25 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

4.

On the Dimension Attributes page, you find three predefined columns, ID, NAME, and DESCRIPTION. Note that for the ID attribute, the identifier is set as Surrogate and for the Name attribute the identifier is set as Business. You can change these attributes to your liking, but must have a surrogate and a business identifier in the . The surrogate identifier must have the NUMBER data type. For the NAME attribute, change Length to 30. Click Next.

Page 26 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

5.

On the Levels page, specify the following levels for the default hierarchy in the dimension:
CATEGORY (Description: Accounting Category) TYPE (Description: As entered on Expense Report)

Page 27 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

Click Next.
6.

On the Level Attributes page, for each level that you have defined, you select the dimension attributes that apply to that level. Accept the default selection and click Next.

Page 28 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

7.

On the Slowly Changing Dimension page, leave the default slowly changing dimension option selected. Click Next.

Page 29 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

Note: SCD Type 2 and 3 are available with the Enterprise ETL option of OWB 10gR2. With Core ETL features, SCD Type 1, that is, Do not keep history option, is only available. If you select any other policy, Warehouse Builder defaults the implementation to the lowest level of the hierarchy and creates the date attributes for you. Click Next on the Pre Create Settings Page. The Dimension Creation Progress page appears. On successful completion, click Next. Click Finish on the Summary page. Observe that REL_CATEGORY dimension has been added to the YOUR DW NAME target module. With the dimension, Warehouse Builder also creates a table that implements the dimension in a star schema and also creates a sequence to load the ID column of the dimension.

Page 30 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

Designing Cubes/Facts
Cubes contain measures and link to one or more dimensions. The axes of a cube contain dimension values and the body of the cube contains measure values. Most measures are numeric and additive. For example, sales data can be organized into a cube whose edges contain values for Time, Product, and Customer dimensions and whose body contains values from the measures Value sales and Dollar sales. In a relational implementation, a cube is linked to dimension tables by foreign key constraints and consists of a set of measures. To create a cube, you must define the following:
Cube Measures Cube Dimensionality

Let us examine a fictive SALES cube for its measures and dimensionality. This topic introduces you to an example of a cube. By examining an existing cube that has been predefined for you, you will understand the basic design of a cube. Later in the topic, you create a simple cube with reference to expenses scenario using the wizard.
1.

In the Project Explorer panel, expand YOUR PROJECT > Databases > Oracle. Expand YOUR DW, and then expand Cubes. Right-click SALES and select Open Editor. Page 31 of 43

Warehouse Builder

Dimensional Design

Dimensional Design
Note: Alternatively, you can also double-click SALES.

The Data Object Editor launches.


2.

In the Dimensional panel in the middle, scroll up or down to understand the design diagram. You will observe that the SALES cube is linked to five dimensions: PRODUCTS, CHANNELS, CUSTOMERS, PROMOTIONS, and TIMES.

Page 32 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

3.

To examine the dimensionality of the SALES cube, click the Dimensions tab in the Cube Details panel in the lower-right corner of the Data Object Editor. Observe that the SALES cube is linked to levels within the five dimensions. For example, SALES cube refers to PRODUCT level of the PRODUCTS dimension. The Role column displays in a drop-down , the dimension roles (if defined previously) that the selected dimension contains.

Page 33 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

4.

To examine the measures of the SALES cube, click the Measures tab in the Cube Details panel. Note that there are three measures and all of them are numeric. These measures can be aggregated to determine the total sales cost, amount, or quantity across a period of time or for a particular customer or for a particular product.

5.

Click the Aggregation tab to define the aggregations that must be performed for each dimension that the cube references. You select the aggregate function that is used to aggregate data. You can also precompute measures along each dimension that the cube references. The default aggregate function is SUM. You specify the following: Page 34 of 43

Warehouse Builder

Dimensional Design

Dimensional Design
Cube Aggregation Method: Select the aggregate function used to aggregate the cube data. The default selection is SUM. Summary Refresh Method: Select the data refresh method. The options you can select are On Demand and On Commit. Summary Strategy for Cube: Define the levels along which data should be precomputed for each dimension.

6.

You can implement a cube in a relational form or a multidimensional form in the database. In relational implementation, a relational table stores the cube data. When a cube is implemented in a multidimensional environment, the cube data is stored in an analytic workspace. If you want to modify the physical implementation of the cube, click the Storage tab in the Cube Details panel. You can select between relational or multidimensional implementation. For relational implementation of the cube, you can opt to create bitmap indexes. Having these indexes on the cube improves your performance at query time.

Page 35 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

As for dimensions, you can view the cube data in the Data Viewer. From the Diagram menu, select Close Window to exit the Data Object Editor.

Create REL_EXPENSE Cube Using the Wizard


Now, you design a simple relational cube, REL_EXPENSE. This cube references the two dimensions, REL_TIME and REL_CATEGORY, which you created in previous steps. The wizard helps you create a cube in a few easy steps.
1.

You were previously examining the YOUR DW module. Now, switch to the YOUR DW NAME module, right-click Cubes, and select New > Using Wizard.

Page 36 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

The Create Cube Wizard is launched. Click Next on the Welcome Page.
2.

On the Name and Description page, enter REL_EXPENSE as the name of the cube. Click Next.

Page 37 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

3.

On the Storage Type page, select ROLAP: Relational Storage to specify relational implementation of the cube. Click Next.

Page 38 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

4.

On the Dimensions page, you select the dimensions that the cube will refer to. In the Available Dimensions , expand Dimensions, and then expand YOUR DW NAME. Select YOUR DW NAME, and then click > to move the two dimensions REL_CATEGORY and REL_EXPENSE to Selected Dimensions . Click Next.

Page 39 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

5.

On the Measures page, enter EXPENSE in the Name field. Accept the default data type. Click Next.

Page 40 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

On the Summary page, review the cube details and click Finish. Observe that REL_EXPENSE cube is added under the Cubes node of the YOUR DW NAME module. To view the cube in the Data Object editor, right-click REL_EXPENSE and select Open Editor or double-click REL_EXPENSE. Examine the cube, and then close the Data Object Editor.

Page 41 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

From the Design menu, select Save All to commit your work. In this lesson, you created two external tables mapped to the two previously sampled source flat files, two dimensions, REL_TIME and REL_CATEGORY, and a cube REL_EXPENSE linked to the two dimensions.

Page 42 of 43

Warehouse Builder

Dimensional Design

Dimensional Design

Page 43 of 43