Designing ETL Data Flow Mappings

Designing ETL Data Flow Mappings

ETL stands for Extract Transform and Load. ETL involves the movement and transformation of data from your sources to your targets. This lesson will teach you about Warehouse Builder's mappings.

This lesson begins with brief overview of mappings. You will create a mapping that will use operators to define the ETL operations that move data from a source object to a data warehouse target object. While defining mappings you will learn to use the Mapping Editor, Attribute Property sheets, Expression Builder, Code Editor.

Topics

This lesson will discuss the following:

Overview
Prerequisites
Overview of Mappings

Defining a Mapping to load the WAREHOUSE Dimension

Defining a Mapping to Load the Inventories Cube
Summary

This lesson will take approximately 60 minutes to complete.

Move your mouse over this icon to show all screenshots. You can also move your mouse over each individual icon to see only the screenshot associated with it.


Overview

In this lesson you will learn one of the Warehouse Builders capabilities, defining mappings and using the Mapping Editor, the interface for defining what you want to transform and map. The mapping editor uses an operator for each operation you want to perform, and a series of operations defines a mapping. By the end of the lesson you will have learned to create a mapping that loads the WAREHOUSE dimension and the second mapping that loads the INVENTORIES cube.

 

Back to Topic List

Back to Topic List

In order for this lesson to work successfully, you will need to have performed the following:

1.

Completed Overview lesson.

2.

Completed Logging in to OWB lesson.

3.

Completed Importing Source Metadata lesson.

4.

Completed Defining Target Module lesson.

5.

Completed Dimensional Design using Oracle Warehouse Builder lesson.

 

Overview of Mappings

Back to Topic List

A Mapping describes a series of operations that pulls data from sources, transforms it, and loads it into targets. Mappings provide a visual representation of the flow of the data from sources to targets and the operations performed on the data.

In this topic you will examine a simple pre defined mapping MAP_EMPLOYEES_INITIAL_LOAD_STG. The MAP_EMPLOYEES_INITIAL_LOAD_STG mapping implements data load from a flat file definition into a relational table. Warehouse Builder generates a SQL loader control file in this case.

1.

In the OWB10g_DEMO project, expand Databases, expand the Oracle node and expand the STG (stands for Staging) module. Expand the Mappings node and select the MAP_EMPLOYEES_INITIAL_LOAD_STG mapping.

Move your mouse over this icon to see the image

 

2.

Double click the MAP_EMPLOYEEES_INITIAL_LOAD_STG mapping. This opens up the selected mapping in the mapping editor.

Move your mouse over this icon to see the image

This mapping loads data from a flat file definition into a relational table.

 

3.

From the Mapping menu, select Generate > Mapping.

Move your mouse over this icon to see the image

 

 

4.

Before the Mapping is generated Warehouse Builder validates it.

Move your mouse over this icon to see the image

The code viewer displays the SQL loader control file.

Move your mouse over this icon to see the image

Close the code viewer window. Close the Mapping Editor.

Instead of writing the code for this file manually, you use Warehouse Builder to graphically design the mappings. After the design you select generate and Warehouse Builder takes care of the most optimal code.

 

 

Defining a Mapping to load the WAREHOUSE Dimension

Back to Topic List

In this topic you will learn to create a mapping that loads the WAREHOUSE dimension. When you create a mapping, you use operators to define the Extraction, Transformation, and Loading (ETL) operations that move data from a source object to a data warehouse target object. The Mapping Editor contains a toolbox that visually represents the operators.

Create a Mapping
Adding a Mapping Dimension and a Mapping Table
Adding a Mapping Key Lookup

Attribute by Attribute Mapping

Setting Loading Type Property
Generate Mapping


Create a Mapping

Back to Subtopic List

In this topic you will learn how to create a Mapping MAP_WAREHOUSE.

1.

In the OWB10g_DEMO project, expand Databases, expand the Oracle node and expand the WH module. Right click the Mapping node. Select Create Mapping.

Move your mouse over this icon to see the image

 

2.

The New Mapping Wizard: Name page appears. Type MAP_WAREHOUSE as the name of the mapping and click OK.

Move your mouse over this icon to see the image

 


3.

The Mapping Editor: MAP_WAREHOUSE opens. The Mapping Editor contains a toolbox that visually represents the operators.

Move your mouse over this icon to see the image

In the next topic you will use the Mapping Editor to drag the various operators from the floating toolbox to the mapping canvas.


 

Adding a Mapping Dimension and Mapping Table

Back to Subtopic List

In this topic you will learn to add a Mapping Dimension and Mapping Table operator in the Mapping Editor. All mappings are based on mapping operators. A mapping operator is a logical representation of a physical repository object.

1.

From the Toolbox Drag and drop the Mapping Dimension icon on to the Mapping canvas.

Move your mouse over this icon to see the image

 


2.

The Add Mapping Dimension dialog opens. Select option Select from existing repository Dimension and bind.

Move your mouse over this icon to see the image

 


3.

Expand WH node (if not expanded), select WAREHOUSE dimension and click OK.

Move your mouse over this icon to see the image

 


4.

The WAREHOUSE Dimension appears on the Mapping Editor. Right click the title at the top of the Warehouse Dimension and from the shortcut menu select Resize To Fit.

Move your mouse over this icon to see the image

The Resize to fit option will show all attributes.

Move your mouse over this icon to see the image


5 .

To add a Mapping Table operator, drag and drop on to the Mapping Editor, the Mapping Table icon from the toolbox.

Move your mouse over this icon to see the image

The Add Mapping Table dialog opens. Select option Select from existing Repository table and bind.

Move your mouse over this icon to see the image

 

6 .

Expand the OE source module select WAREHOUSES table and click OK.

Move your mouse over this icon to see the image

The next topic will demonstrate how to use Key Lookup operator.


 

Adding a Mapping Key Lookup

Back to Subtopic List

The Key Lookup operator reads data from a lookup table by using the key input that you supply and finds the matching rows. The mapping MAP_WAREHOUSE needs lookups to table definitions LOCATIONS and COUNTRIES.

1.

Drag and drop the Key Lookup operator on to the Mapping Editor.

Move your mouse over this icon to see the image

The Add Mapping Key Lookup dialog opens. Select option Select from existing Repository Key Lookup and bind.

Move your mouse over this icon to see the image


2.

Select COUNTRIES table from the HR module, press CTRL on the keyboard and select LOCATIONS from the HR module and click OK.

Move your mouse over this icon to see the image

 

3 .

Maximize the Mapping Editor window. Spread the operators across the canvas.

Move your mouse over this icon to see the image

 

4 .

Right click the LOCATIONS key lookup operator and select Resize to Fit to see full attribute name and list of attributes

Map attribute LOCATION_ID from the WAREHOUSES table to the LOCATIONS key lookup operator.

Click on LOCATION_ID under INOUTGRP1 from WAREHOUSES mapping table and drag a line to INGRP1 of LOCATIONS.

Move your mouse over this icon to see the image

Move your mouse over this icon to see the image

 

5 .

Define the Key Lookup condition.

Right click the LOCATIONS operator and select Operator Properties....

Move your mouse over this icon to see the image

 

6 .

The Key Lookup Properties window appears, Click on the field next to Lookup Condition and click the three-dotted button on the right (...).

Move your mouse over this icon to see the image

 

 

7 .

The Lookup Condition dialog appears, Click Add to List.

Move your mouse over this icon to see the image

 

8 .

The Match Key Columns to Inputs for key LOC_ID_PK dialog appears. Here you create key lookup conditions by matching source attributes with the lookup table key attributes and click OK.

Move your mouse over this icon to see the image

.

 

9 .

The Lookup Condition dialog reappears review the Key Lookup condition and click OK.

Move your mouse over this icon to see the image

The Key Lookup Properties window is displayed. Close the Key Lookup Properties.

Move your mouse over this icon to see the image

 

10 .

Right click the LOCATIONS Key Lookup operator and select Resize to Fit.

Move your mouse over this icon to see the image

 

11 .

Map attribute COUNTRY_ID from the LOCATIONS key lookup to the COUNTRIES key lookup operator.

Drag a line from COUNTRY_ID attribute in OUTGRP1 of LOCATIONS key lookup into INGRP1 of COUNTRIES.

Move your mouse over this icon to see the image

Move your mouse over this icon to see the image

 

 

12 .

Define the Key Lookup condition.

Right click the COUNTRIES key lookup operator and select Operator Properties...

Move your mouse over this icon to see the image

 

13 .

The Key Lookup Properties window appears, Click on the field next to Lookup Condition and click the three-dotted button on the right (...).

Move your mouse over this icon to see the image

 

14 .

The Lookup Condition dialog appears, Click Add to List.

Move your mouse over this icon to see the image

 

15 .

The Match Key Columns to Inputs for key COUNTRY_C_ID_PK appears. Here you create key lookup conditions by matching source attributes with the lookup table key attributes and click OK.

Move your mouse over this icon to see the image

 

16 .

The Lookup Condition dialog reappears review the Key Lookup condition and click OK.

Move your mouse over this icon to see the image

The Key Lookup Properties window appears with the condition displayed. Close the Key Lookup Properties window.

Move your mouse over this icon to see the image

 

 

Attribute by Attribute Mapping

Back to Subtopic List

This topic demonstrates an attribute by attribute mapping.

1.

Right click the WAREHOUSES table and select Resize to Fit. Right click the WAREHOUSE dimension and select Resize to Fit.

Drag a line from WAREHOUSE_ID from the WAREHOUSES table to WRE_ID in the WAREHOUSE dimension.

Move your mouse over this icon to see the image

Move your mouse over this icon to see the image

 

2.

Drag a line from WAREHOUSE_NAME from the WAREHOUSES table to WRE_NAME in the WAREHOUSE dimension.

Move your mouse over this icon to see the image


3 .

Drag a line from LOCATION_ID from OUTGRP1 of LOCATIONS key lookup operator to LCN_ID in the WAREHOUSE target dimension.

Move your mouse over this icon to see the image


4 .

Drag a line from CITY from the LOCATIONS key lookup operator to LCN_CITY in the WAREHOUSE target dimension.

Move your mouse over this icon to see the image


5 .

Drag a line from STATE_PROVINCE from the LOCATIONS key lookup operator to LCN_STATE_PROVINCE in the WAREHOUSE target dimension.

Move your mouse over this icon to see the image


6 .

Right click the COUNTRIES key lookup operator and select Resize to Fit. Drag a line from COUNTRY_ID from OUTGRP1 of COUNTRIES key lookup operator to CTY_ID in the WAREHOUSE target dimension.

Move your mouse over this icon to see the image


7 .

Drag a line from COUNTRY_NAME from the COUNTRIES key lookup operator to CTY_NAME in the WAREHOUSE target dimension.

Move your mouse over this icon to see the image


Setting Loading Type Property

Back to SubTopic List

In this topic you will select a loading type for the WAREHOUSE dimension target operator.

1.

Right click the WAREHOUSE target dimension (click on the upper bar that displays WAREHOUSE) and select Operator Properties....

Move your mouse over this icon to see the image

 

2.

The Mapping Dimension Properties dialog appears. In this example WAREHOUSE records are not only inserted but updated as well.

Click on the field next to Loading Type and select UPDATE/INSERT from the drop-down box and close the Mapping Dimension Properties dialog.

Move your mouse over this icon to see the image

Move your mouse over this icon to see the image

Generating Mapping

Back to SubTopic List

In this topic you will learn how to generate a Mapping.

1.

In the Mapping Editor, right click the INOUTGRP1 on the WAREHOUSE dimension and select Generate Intermediate Results.

Move your mouse over this icon to see the image

 

2.

The Code Viewer window pops up and shows a set based MERGE statement. Before Warehouse Builder generates the most optimal code for the update/insert on the WAREHOUSE dimension it will do a validation for the selected object. Close the Code Viewer window. Close the Mapping Editor.

Move your mouse over this icon to see the image

Move your mouse over this icon to see the image

 

 

 

Defining a Mapping to Load the INVENTORIES Cube

Back to Topic List

In this topic you will learn to create a mapping to load the INVENTORIES cube and use some more mapping operators from the floating toolbox in the Mapping Editor.

Create a Mapping
Adding a Mapping Cube
Adding a Mapping Table

Adding a Constant

Adding an Expression
Adding an Aggregator
Adding a Mapping Key Lookup
Generate Intermediate Results

 

Creating a Mapping

Back to SubTopic List

In this topic you will create a mapping MAP_INVENTORIES.

1.

In the OWB10g_DEMO project, expand Databases, expand the Oracle node and expand the WH target module. Right click the Mappings node and select Create Mapping.

Move your mouse over this icon to see the image

 

2.

The New Mapping Wizard: Name page appears. Type MAP_INVENTORIES as the name of the mapping and click OK.

Move your mouse over this icon to see the image

 


3.

The Mapping Editor: MAP_INVENTORIES window opens. The Mapping Editor contains a toolbox that visually represents the operators.

Move your mouse over this icon to see the image

In the next topic you will learn to use some more new operators from the floating toolbox.


 

Adding a Mapping Cube

Back to SubTopic List

In this topic you will drag and drop the cube icon from the floating toolbox on to the Mapping canvas.

1.

In the Mapping Editor, from the Toolbox drag and drop the Mapping Cube operator to the canvas.

Move your mouse over this icon to see the image

 

2.

The Add Mapping Cube dialog is displayed. Select option Select from existing repository Cube and bind. Under the WH target module select the INVENTORIES cube. Click OK.

Move your mouse over this icon to see the image

 


3.

The Mapping Editor: MAP_INVENTORIES window opens.

Move your mouse over this icon to see the image

You will learn how to use some more operators from the Toolbox.


Adding a Mapping Table

Back to SubTopic List

In this topic you will add a Mapping Table operator to the MAP_INVENTORIES mapping.

1.

In the Mapping Editor window, drag and drop the Mapping Table operator to the canvas.

Move your mouse over this icon to see the image

 

2.

The Add Mapping Table dialog appears. Select option Select from existing repository Table and bind. From the OE source module select the INVENTORIES table and click OK.

Move your mouse over this icon to see the image

 


3.

The Mapping Editor: MAP_INVENTORIES window is displayed with the INVENTORIES mapping table and INVENTORIES mapping cube.

Move your mouse over this icon to see the image

 


 

Adding a Constant

Back to SubTopic List

In this topic you will add a Constant to the MAP_INVENTORIES mapping.

1.

In the Mapping Editor: MAP_INVENTORIES, drag and drop a Constant operator on to the canvas.

Move your mouse over this icon to see the image

 

2.

In the Mapping Editor, right click the CONST operator and select Edit.

Move your mouse over this icon to see the image

 


3.

The Constant Editor: CONST window appears. Select the Output Attributes tab and click Add.

Move your mouse over this icon to see the image

Move your mouse over this icon to see the image


4.

Rename the OUTPUT1 attribute to TODAY, change the NUMBER datatype to DATE and click OK.

Move your mouse over this icon to see the image

The CONST operator in the Mapping Editor now has the TODAY attribute.

Move your mouse over this icon to see the image

 

5.

In the Mapping Editor right click on attribute TODAY and select Attribute Properties.

Move your mouse over this icon to see the image

 

6.

The Attribute Properties: TODAY dialog appears. Click on the field next to Expression and click the three-dotted button (...).

Move your mouse over this icon to see the image

 

7.

The Expression dialog displays. In the Expression for: TODAY field type sysdate.

Move your mouse over this icon to see the image

Optionally you can click Validate to validate your expression, on success the message Validation Successful is displayed in the Validation results field.

Move your mouse over this icon to see the image

 

8.

Click OK to close the Expression dialog. Close the Attribute Properties: TODAY dialog.

Move your mouse over this icon to see the image

 

 

Adding an Expression

Back to SubTopic List

This mapping needs the month name. In this topic you will learn how to achieve this description, by using an expression.

1.

In the Mapping Editor, from the Toolbox drag and drop the Expression operator on to the canvas.

Move your mouse over this icon to see the image

 

2.

Drag a line from the attribute TODAY of the CONST operator into INGRP1 of the expression EXPR

Move your mouse over this icon to see the image

Move your mouse over this icon to see the image


3.

Right click the EXPR operator and select Edit.

Move your mouse over this icon to see the image

 


4.

The Expression Editor appears. Select the tab Output Attributes and click Add.

Move your mouse over this icon to see the image

 


5.

Rename the OUTPUT1 attribute with MONTH_NAME and NUMBER datatype to VARCHAR2, and length 7. Click OK.

Move your mouse over this icon to see the image

 


6.

(Right click on EXPR operator and select Resize to Fit to be able to see all the attributes)

In the Mapping Editor right click the MONTH_NAME output attribute on OUTGRP1 of EXPR and select Attribute Properties.

Move your mouse over this icon to see the image

 


7.

The Attribute Properties dialog displays. Click next to the Expression field, and click on the three-dotted button (...).

Move your mouse over this icon to see the image

 


8.

The Expression dialog displays. Expand the INGRP1 to see all attributes.

Move your mouse over this icon to see the image

Move your mouse over this icon to see the image

 


9.

At the top of the right panel is the Expression field. In this field you will type the expressions. Follow the numbered instructions.

1. Enter to_char(
2. Double click the TODAY operator under INGRP1 on the left-hand side of the Expression dialog. The expression looks like to_char(INGRP1.TODAY
3. Add the symbol comma ( , ). The expression looks like to_char(INGRP1.TODAY ,
4.

Enclose in single quotes 'MONYYYY' followed by the symbol close bracket ( ) ) to complete the expression.

Finally the expression looks like to_char(INGRP1.TODAY , 'MONYYYY')

 

Move your mouse over this icon to see the image

Optionally you can click Validate to validate the expression.

 

10.

Click Ok and close the Attribute Properties dialog.

Move your mouse over this icon to see the image

 


Adding an Aggregator

Back to SubTopic List

The Aggregator operator performs data aggregations, such as SUM and AVG, and provides an output row set with aggregated data. In this topic you will learn how to define an aggregator operator.

1.

In the Mapping Editor, from the Toolbox, drag the Aggregator operator and drop it on the canvas.

Move your mouse over this icon to see the image

 

2.

(Right click on INVENTORIES_1 mapping table operator and select Resize to Fit to be able to see all the attributes)

Map attributes from INVENTORIES_1 mapping Table to AGG Aggregator:

Drag a line from PRODUCT_ID of INVENTORIES mapping table to INGRP1 of AGG operator

Move your mouse over this icon to see the image

 

3.

Map attributes from INVENTORIES_1 Mapping Table to AGG Aggregator:

Drag a line from WAREHOUSE_ID of INVENTORIES_1 mapping table to INGRP1 of AGG operator

Move your mouse over this icon to see the image

 

4 .

Map attributes from INVENTORIES_1 Mapping Table to AGG Aggregator:

Drag a line from QUANTITY_ON_HAND of INVENTORIES_1 mapping table to INGRP1 of AGG operator

Move your mouse over this icon to see the image

 

5.

Map Attributes from EXPR expression to AGG aggregator operator:

Drag a line from MONTH_NAME of EXPR operator to INGRP1 of AGG operator.

Move your mouse over this icon to see the image

 

6.

Right click aggregator AGG and select Operator Properties..

Move your mouse over this icon to see the image

 

7.

The Aggregator Properties dialog opens. Click in the field next to Group By Clause and click the three-dotted button (...)

Move your mouse over this icon to see the image

 

8.

The Group by Clause dialog pops up. Here you specify how the rows are grouped to return a single row for each group.

Move your mouse over this icon to see the image

From the Available Attributes list select INGRP1.PRODUCT_ID and move to the right-hand side GROUP BY Attributes list using the single greater than symbol ( > ).

Select INGRP1.WAREHOUSE_ID and move to the right-hand side list using the single greater than symbol ( > ).

Select INGRP1.MONTH_NAME and move to the right-hand side list using the single greater than symbol ( > ).

Move your mouse over this icon to see the image

 

9.

Click OK to close the Group By Clause dialog. Close the Aggregator Properties dialog.

Move your mouse over this icon to see the image

 

10.

Right click aggregator AGG, and select Edit.

Move your mouse over this icon to see the image

 

11.

The Aggregator Editor: AGG appears. Click on the Output Attributes tab and click Add.

Move your mouse over this icon to see the image

 

</
12.

Rename the OUTPUT1 attribute with AMOUNT. Click OK to close Aggregator Editor: AGG dialog.

Move your mouse over this icon to see the image