Obiee Developers Guide
Obiee Developers Guide
Oracle Business Intelligence 11g is Oracle Corporation’s platform for delivering business
intelligence across a complete range of data sources, applications, and business processes.
It consists of a number of servers, query and analysis tools, plug-ins to popular third-party
applications such as Microsoft Office, and tools for managing business metadata.
If your organization has recently licensed Oracle Business Intelligence to provide reporting,
analysis, and dashboards across your organization—congratulations! You have made a wise
decision. However, like most enterprise-class software products, Oracle Business Intelligence
is a complex product that rewards those developers who take the time to learn how to
correctly configure, build, and then deploy solutions built using it. By purchasing this book,
you will gain a great introduction to the complexities of Oracle Business Intelligence, together
with an invaluable reference for when you hit those tricky technical issues.
This book takes you through the complete life cycle for deploying Oracle Business
Intelligence within your organization, and it is based on the 11g Release 1 (11.1.1.6) version
of the product. The assumed audience for the book is developers who will be responsible for
installing, configuring, and developing the initial business intelligence solution, who also need
to know something about the internals of the product and how it has been put together.
Chapter 8: “Security”
In this chapter, you’ll learn about the security capabilities of Oracle Business Intelligence, how
to create users, groups, and application roles, how to use them to apply catalog content and
row-level filtering, and how to integrate with external directories such as Microsoft Active
Directory.
Intended Audience
This book is suitable for the following readers:
Developers who need to create repositories against relational, OLAP, and other data
sources, integrate BI with business processes and applications, and support business
users creating analyses, dashboards, and reports
Administrators and support staff who need to understand the systems management
features of Oracle Business Intelligence, clustering and high-availability options, and
how to support deployments into production
Business users who need to create ad-hoc analyses, dashboards, reports, KPIs,
scorecards, and other BI content
Technical managers or consultants who need an overview of the capabilities and
architecture of Oracle Business Intelligence
No prior knowledge of Oracle Business Intelligence is required for this book, but a basic
understanding of databases, SQL, reporting, and analysis is assumed.
Considering this four-tier architecture from the perspective of an end user requesting a
dashboard of business information, the components within Oracle Business Intelligence
perform the following high-level functions to return data to the user:
1.The web browser requests a dashboard of data, consisting of analyses, published
reports, and other BI content.
2.This request is received by the Oracle BI Presentation Server, which translates
requests for individual analyses and reports into logical SQL queries. These logical
queries are then passed to the Oracle BI Server.
3.The Oracle BI Server takes these logical SQL queries, written against the semantic
model contained in the Oracle BI Repository, and translates them into native SQL and
MDX queries that are then sent to the underlying data sources.
4.The underlying data sources process the native SQL and MDX queries, and return
results to the Oracle BI Server.
5.The Oracle BI Server returns a data result set to the Oracle BI Presentation Server.
In instances where more than one data source is needed to satisfy the query, the BI
Server is capable of combining multiple data sets into a single set of results.
6.Finally, the Oracle BI Presentation Server presents the results back to the end user,
in the form of analyses, published reports, dashboards, and other BI content.
Unlike many other business intelligence tools that combine data presentation with query
generation in a single server, Oracle Business Intelligence splits these functions into two
separate servers:
Oracle BI Server This server provides simultaneous connectivity to heterogeneous
data sources, a calculation and data federation engine, access to a semantic
(metadata) model, and a security layer.
Oracle BI Presentation Server This server connects to the Oracle BI Server and
provides users with a catalog of analyses, reports, and dashboards that they can use
to analyze their data.
Oracle Business Intelligence 11g actually makes use of other servers to handle clustering,
scheduling of reports, and other services; but, for now, consider these two servers the “core”
of the Oracle Business Intelligence’s functionality.
In addition to these, it provides other, industry-specific “vertical” packaged applications for the
financial services, pharmaceuticals, and other industries. Figure 1-7 shows the relationship
between Oracle Business Intelligence Applications and Oracle Business Intelligence, and how
data for this combined system is either accessed directly from application and database data
sources, or through a prebuilt data warehouse fed by predefined data extraction routines.
Installing the Microsoft Loopback Adapter with Microsoft Windows Server 2003
To install the Microsoft Loopback Adapter using either the 32- or 64-bit version of Microsoft
Windows Server 2003, follow these steps, which assume that you have one other network
adapter already installed that connects you to your corporate network or the Internet (or
adjust the network adapter naming in the steps if this is not the case):
1. Log into your Microsoft Windows Server 2003 using an account with administrator
privileges.
2. Select Start to bring up the Windows Start menu; then select Settings | Control Panel.
3. When the Control Panel window is displayed, double-click the Add Hardware icon to
display the Add Hardware Wizard.
4. Click Next to progress past the opening screen in the wizard, and when asked “Is the
hardware connected?” select the radio button for “Yes, I have already connected the
hardware.”
5. The wizard will then present you with a list of already installed hardware. Scroll to the
bottom of the list, select Add A New Hardware Device, and click Next.
6. On the next screen of the wizard, select the “Install the hardware that I manually select
from a list (Advanced)” radio button, and then click Next.
7. From the list of common hardware types displayed on the next screen of the wizard,
select Network Adapters from the list and click Next.
8. On the Select Network Adapter screen, select Microsoft in the Manufacturer list and
Microsoft Loopback Adapter in the Network Adapter list; then click Next.
Click Next and then Finish to compete the installation.
Now that the loopback adapter is installed, you need to give it a static IP address. To do this,
follow these steps:
1.Select Start to bring up the Windows Start menu; then select Settings | Control
Panel.
2.From the list of icons in the Control Panel window, select Network Connections.
3.Within the Network Connections window, there should be a new network adapter
listed called Local Area Connection 2. (The number may differ if you have more than
one physical network adapter installed.) This network adapter will be labeled as using
the Microsoft Loopback Adapter, and there should be a message stating that it has
limited or no connectivity.
4.Double-click this new network adapter icon, and when the Local Area Network
Connection 2 Status dialog box is shown, click the Properties button.
5.With the Properties dialog box displayed, ensure that the General tab is selected and
then double-click the Internet Protocol (TCP/IP) entry, so that you can set the static IP
address for the network adapter.
6.With the Internet Protocol (TCP/IP) Properties dialog box shown, select the “Use the
following IP address” radio button and enter the following details:
IP address: 10.10.10.10
Subnet mask: 255.255.255.0
Leave all other values blank, or at their default value.
Click OK and then OK again to close the various dialog boxes. When you view the Local Area
Connection 2 icon within the Network Connections window now, you should see that its status
has changed to Connected.
Installing the Microsoft Loopback Adapter with Microsoft Windows Server 2008
To install the Microsoft Loopback Adapter using the 32- or 64-bit version of Microsoft Windows
Server 2008, follow these steps, which assume that you have one other network adapter
already installed that connects you to your corporate network or the Internet (or adjust the
network adapter naming in the steps if this is not the case):
1. Log into Microsoft Windows Server 2008 using an administrator account.
2. Select Start to bring up the Windows Start menu, and in the search box at the bottom
of the screen, type Device Manager.
3. When the Device Manager dialog box is shown, right-click the machine name at the top
of the device list and select Add Legacy Hardware.
The Add Hardware Wizard will then be displayed. Click Next, select the “Install the hardware
that I manually select from a list (Advanced)” radio button on the next screen, and then click
Next to proceed.
1.Click Next to have the wizard search for new hardware, and then click Next when it
does not find the loopback adapter. When the list of common hardware types is then
shown on the subsequent screen, select Network Adapters and click Next.
2.At the Select Network Adapter screen, select Microsoft in the Manufacturer list and
Microsoft Loopback Adapter in the Network Adapter list.
The Local Area Network Connection 2 Status dialog box will then be displayed. Click the
Properties button at the bottom of the dialog box to display the Properties dialog box, and
then, with the Networking tab selected, double-click the Internet Protocol Version 4
(TCP/IPv4) entry.
1.In the Internet Protocol Version 4 (TCP/IPv4) Properties dialog box that appears,
select the “Use the following IP address” radio button and enter the following details:
IP address: 10.10.10.10
Subnet mask: 255.255.255.0
Leave the remaining entries in the dialog box blank, or at their default value.
1. Click OK, and OK again; then click Close to close the various dialog boxes.
Network Settings
Unlike Microsoft Windows–based installations, you do not need to install a separate loopback
adapter before installing Oracle Business Intelligence. Instead, using a text editor, edit the
/etc/ hosts file so that it contains the following entries (substituting your own host name for
obisrvlnx64, as appropriate), which then ensure that requests made to your machine’s host
name are directed to the pre-installed loopback adapter:
127.0.0.1 obisrvlnx64
127.0.0.1 localhost.localdomain localhost
To check that your host name now resolves back to the loopback IP address, use the
/bin/ping utility to check connectivity. The results of this check should look like this:
In general, Unix and Linux systems take their machine name from this hosts file entry, so if
you see the machine name displayed at the command prompt like this, you can usually be
reasonably confident that the host name will resolve properly.
The Oracle BI Repository is used alongside another metadata store within Oracle Business
Intelligence, and that is the Oracle BI Presentation Server Catalog. The Oracle BI
Presentation Server Catalog, or “catalog” for short, contains definitions of analyses,
dashboards, agents, conditions, scorecards, and other BI objects that users create in order to
analyze their data. As such, then, an Oracle Business Intelligence system can be thought of
as containing three layers of data and metadata, listed here and shown in Figure 3-2:
The Oracle BI Presentation Server Catalog, containing the report definitions
The Oracle BI Server Repository, containing the logical dimensional model used to
populate the reports
The underlying databases, OLAP cubes, and other data sources that actually contain
the data
The main user of metadata from the Oracle BI Repository is Oracle BI Answers, the analysis
editor and ad-hoc query component within the Oracle Business Intelligence web site.
Other users of this metadata include Oracle BI Publisher, which allows report developers to
create reports using data from the repository, and third-party reporting tools, which can work
with the repository through the Oracle BI ODBC client.
The repository is traditionally stored in a single, binary file within the middleware home
directory structure, which is typically at
[middleware_home]\instances\instance1\bifoundation\OracleBIServerComponent\coreapplicat
ion_obis1\repository
with the file having an “.rpd” suffix, such as the SampleAppLite.rpd that ships with every
installation of Oracle Business Intelligence 11g.
This file is encrypted using a password, and like any operating system file, while it can be
read by many processes in parallel, only one can write to it at any one time. This, as you will
see, has implications for team development because you will need to serialize write access to
this file using one means or another.
With the 11.1.1.6 release of Oracle Business Intelligence, a new storage format for the
repository was introduced, called MDS XML Documents. This storage format is primarily used
when integrating Oracle Business Intelligence with source-control systems, as it breaks the
repository down into individual XML files that can be checked in and checked out of source
control. In this chapter, we assume that you will be using the traditional, RPD file-based
format, and we cover the new MDS XML format, along with source control, in Chapter 11.
Repositories in either storage format can be accessed either offline or, for RPD file-based
storage only, online. Offline access is when you are directly connecting to the repository file
through, for example, the Oracle BI Administration tool, and in this case only
one developer can access the file at one time in this way. Repositories can also be accessed
online, which involves the BI Server itself connecting to the repository through an ODBC
connection, with subsequent, potentially multiple, connections to the repository then being
routed through the BI Server. You will see the differences between offline and online access to
the repository later in this chapter.
In this chapter, we will focus on relational data sources, along with flat file and XML data
sources. In the following chapter we will cover the additional things you need to know when
working with multidimensional data sources, such as Oracle Essbase and Microsoft Analysis
Services.
Key definitions (and the alias, stored proc, and select table variants) are created within
physical tables, and they define the identifier column for the table (that is, the “primary key”).
This does not have to be the same primary key column that the underlying database uses, but
you must ensure that it uniquely identifies each row and that there are no duplicate values
within the associated column; otherwise, the BI Server may return unexpected or incorrect
results for a query.
If you have created your underlying data sources yourself or you can be absolutely sure that
their primary key definitions are correct, then you can probably just import your key definitions
along with your table and column definitions; if, however, these key definitions do not exist or
you are not sure they are correct, you can choose not to automatically import them and can
instead create them yourself manually after the initial metadata import.
Keys are primarily used when creating physical or complex joins from a master-level table (for
example, one containing dimensional data) to a table containing detail-level data (typically,
data containing facts and measures). These joins tell the BI Server how to retrieve data from
more than one table—and again, they can either be automatically imported from the
underlying database (by reading the foreign key information in the database data dictionary)
or you can create them yourself manually.
Correctly and efficiently setting up keys and joins in your physical layer is probably one of the
most important tasks you will undertake as an Oracle Business Intelligence developer, and
we will explore several scenarios involving different types of keys and joins later in this
chapter. Note that, unlike tools such as Oracle Discoverer, joins can only be set up by an
administrator; and if there is more than one possible join path between two physical tables,
these have to be resolved in advance by the administrator rather than giving the user the
ability to select between them when creating the query.
To allow a table to be joined to more than once. For example, where an ORDERS table
contains multiple foreign key references to a DAY table to represent order date, ship date,
payment date, and return date, you will need to create aliases such as Dim_DAY_Order_Date
and Dim_DAY_Ship_Date for each “role” that the table performs.
To organize sets of physical objects into groups, you can also define physical display folders
under the main database definition, into which you can place sets of physical objects.
Physical display folders are particularly useful if your naming standard is always to work with
aliased table names and you want to place these aliases in a display folder to keep them
separate from your physical table names.
Database Definitions
When defining a new database in the physical layer, you can select from a number of
database servers from different vendors to correspond with how your data is stored.
When a user’s analysis requests data from this logical table, the Oracle BI Server will use one
or several of these logical table sources when sending physical SQL queries to source
databases, depending on which of the logical columns were used in the analysis and the level
of aggregation requested.
Projects
The Oracle BI Repository is in most cases stored in a single, monolithic file, and therefore
Oracle has had to develop a special process for handling concurrent editing of the file. One
such process is the Multiuser Development Environment (MUDE), which allows developers to
check out subsets of the repository, called projects, that are edited separately and then
checked back into the main repository. These projects are defined using the Project Manager
and are pointers to business models, subject areas, variables, users, initialization blocks and
application roles that can then either be manually exported as a project (a subset repository
file) or automatically exported using MUDE.
Projects and multiuser development are described in more detail in Chapter 11.
Identifying Facts
Your source database, if not already a dimensional data warehouse, will typically be a
transactional database designed along the principal of third-normal form modeling. Third-
normal form modeling is a design approach where data is stored just once, in the most space-
efficient manner and in a way that makes transactions as efficient as possible to process.
Your task as a dimensional modeler is to identify those data items within this data model that
will provide the “facts” for your business model.
Candidates for facts are typically data items that record events, and business processes
within your organization. For example, if you are an insurance company, your main business
processes are likely to be the following:
Selling insurance policies
Placing them on risk
Processing claims
Paying commission to salespeople
Similarly, in the examples used in this book, a retail chain selling food and beverages is likely
to run the following key business processes:
Baking cakes and manufacturing sandwiches
Selling food and beverages in the stores
Paying its staff and suppliers
Monitoring quality and running “mystery shopper” exercises
These activities and business processes will form the most likely candidates for the fact tables
in your logical model. Each process will be associated with measures and metrics (how many
sandwiches you sold, how many claims were made), and interviews with potential users of
your business intelligence system should help you focus on what facts and measures you
should have in your model.
Identifying Dimensions
While it would be useful to know the total number of claims or sandwiches your organization
has handled over all the years you have been in business, it’s usually more useful to be able
to break this total figure down by customer type, region, year, and so on. Then, once you start
thinking about year, for example, you realize that it would also be useful to break this figure
down by quarter, month, and sometimes day. It would also be useful to analyze data by other
calendars (or “hierarchies”) such as fiscal, academic, or taxation.
The things that you break facts and measures down by are your dimensions. Dimension
tables are typically organized by theme, such as customer, product, store, or time, with each
dimension typically containing a number of levels and hierarchies. Within your logical
dimensional model, fact tables contain the numbers you wish to analyze, while dimensions
contain the reference data you analyze these numbers by. If you keep your model as simple
as that, you won’t go far wrong.
Identifying Columns
Your source database will typically have hundreds of columns, some of which users are
interested in for reporting on and some of which they aren’t. The temptation, when you aren’t
sure which are which, is to include them all in the logical model and then, through a process
of “natural selection,” monitor which ones are used and which ones you can safely discard.
Instead, focus on bringing into your model just those columns that are needed, which for the
fact table are those containing your measures, and in the dimension tables are those which
either form the dimension unique key or those that will be required by users to make
dimension member selections. If in doubt, leave them out initially, and you can easily add
them in once you have a better handle on your users’ requirements.
In the Create New Repository – Select Data Source dialog box that appears, select the
connection type for your source database from the Connection Type drop-down list, and then
enter the connection details; for example:
Connection Type: Oracle OCI10g/11g
Data Source Name: orcl
User Name: gcbc_sales
Password: password
Note For Oracle sources, the data source name should be the Oracle Net (TNSNAMES)
connection name to your database. See Chapter 2 for details on how to configure the
embedded Oracle Client software within Oracle Business Intelligence to recognize this
connection name.
4.In the Create New Repository – Select Metadata Types dialog box, select the
metadata types (database object types) that you wish to import (for example, table,
keys, and foreign keys).
You will be shown a listing of all of the database objects that your database username
has SELECT privileges for. For this example, we use the dialog box to select the
PRODUCTS, SALES, and TIMES tables from within the GCBC_SALES schema.
4.After initially selecting the metadata objects to import, the Connection Pool dialog box
will be shown. For now, just click Finish to close this dialog box, and we will look in
more detail at the connection pool settings in a moment.
If you look within the physical layer of your new semantic model and expand the database
node, you will see your newly imported source data.
You now have the basic set of tables imported into the physical layer of your semantic model.
Now you can enhance this physical model by creating aliases for the physical tables and then
placing them in a separate display folder.
Step 2: Create Aliases for Imported Table Names, and Physical Display
Folders to Organize Them
Aliases are alternative names for a physical layer object that can be used to make the names
more descriptive or to distinguish between roles for an object. In this example, we will create
aliases for our imported tables to make it clear what role the table plays, as a form of “naming
standard” to make it easier for other people to understand our model.
1. Within the physical layer, locate the database that you have just imported. Right-click
the first of the tables and select New Object | Alias. Use the Physical Table dialog box
to give the alias a name; for example, for a physical table called PRODUCTS that
holds product dimension information, call the new alias Dim_PRODUCTS.
2. Repeat this for the other physical tables, using the following alias prefixes:
Dim_: Source table used for dimension information
Fact_: Source table used for fact (measure) information
Lkp_: Source table used for lookup information
If a table is used for multiple roles, for example, a table containing dates or times,
create an alias for each role that it plays, such as Dim_TIMES_Order_Date,
Dim_TIMES_Ship_DATE, and so on. If a source table contains both dimension and
fact information, create an alias for each of these roles, such as Dim_ORDERS and
Fact_ORDERS. Do this for every table in the physical schema.
3. Once all the aliases are created, right-click the physical database item orcl, and select
New Object | Physical Display Folder. Give the folder a name (for example, GCBC
Sales), and then drag-and-drop the aliases you just created into this new folder.
4. Dragging and dropping the aliases into the display folder copies them there rather than
moving them. To display only these aliases within this folder, from the menu select
Tools | Options, and then select the Repository tab. Select the “Show tables and
dimensions only under display folders” check box and click OK; then return to the
physical layer. Expand the database entry, and you will see that the aliases are shown
now only under the display folder. Going forward, you will only work with these aliases
and not the physical tables you initially imported.
Now that you have renamed and simplified your physical model, you can create or check the
primary and foreign keys.
To create joins (foreign keys) in your physical layer, you can either create them using the table
properties dialog box as with keys, or you can use the Physical Diagram view to create them
graphically. To create joins using the table properties dialog box, select a physical table
containing fact data, right-click it, and select Properties; then select the Foreign Keys tab and
click the Add button to display the Physical Foreign Key dialog box. Use the dialog box to
select the dimension table and column you wish to join to, as well as the fact table column
that joins to them, and click OK to save the join.
Alternatively, to create joins using the Physical Diagram view, using the physical layer to
locate the tables or aliases you wish to join, CTRL-click them to select them all, and then
right-click and select Physical Diagram | Selected Object(s) Only. When the Physical Diagram
view is then displayed, starting with the fact table and with the New Join button selected, click
the fact table and then draw lines (joins) to the dimension tables, selecting the columns to join
on when the Physical Join dialog box is shown. Repeat this step until the SALES fact table is
joined to the TIMES and PRODUCTS dimension tables.
When creating the physical joins, give them a descriptive name such as
Sales_Fact_to_Product_Dim_FK so that you can identify the purpose of the join if it is
referenced in a warning or error raised when using the Consistency Checker, detailed later on
in this chapter.
Step 4: Create the Business Model, Outline Logical Tables, and Add
Logical Columns
Now that you have your initial physical model, you can now start to create the business model
to go with it. Your objectives when creating this business model are to create a dimensional
model consisting of fact tables containing measures, together with dimension tables
containing attributes, to which you will add calculations, hierarchies, and other information
that users will find useful when creating analyses.
To start this process, create empty fact and dimension logical tables, and then join them
together so that the Oracle BI Server knows whether each logical table is a fact or dimension:
1. Using the Oracle BI Administration tool, locate the business model and mapping layer
in the semantic model. Move the mouse pointer to an area away from any other objects
(for your first model, there should be none), right-click and select New Business Model.
2. When the Business Model dialog box is shown, type in the name of the new model (for
example, Sales).
3. When the new business model is then displayed, right-click it and select New Object |
Logical Table).
4. At the Logical Table dialog box, enter the name of the logical table (for example, Fact
Sales). Now repeat steps 3 and 4 to create the remaining logical tables in your
business model, starting with the fact tables and then moving on to the dimension
tables.
Now you can start adding columns to the logical tables you just created. Starting with the fact
table, locate the column in the physical layer that you wish to map across, and then drag-and-
drop it from the physical model into the logical fact table. Notice how within the Sources folder
in your logical fact table you now have an entry with the same name as the source table.
When adding columns to the fact table, only drag the measure (numeric) columns across, not
the dimension ID columns, as the Oracle BI Server takes care of the join for you in the
background based on the keys and joins you set up in the physical layer of the semantic
model. Make sure you drag across the dimension key columns, though, as you will need
these later on to create your logical table keys. In some situations, you might need to source
columns for a logical table from more than one physical table. Later on in this chapter, we will
take a look at a number of situations where this is the case, and how you model this in the
repository.
Once you have added all of the columns to your logical model, rename them so that they use
regular business names rather than the system names that were used in the source
database. For example, you might want to rename the incoming logical column
FCAST_SAL_AMOUNT to Amount Sold so that users are better aware of the meaning of the
column. To rename a column, either select it and then single-click it to open the name for
editing or right-click the logical column and select Rename.
Note Never rename columns in the physical layer unless the name has also changed in the
underlying database, as doing so may cause errors when the Oracle BI Server tries to
access the database source.
7. Finally, you need to set the default aggregation rule for the measure columns in your
logical fact table. To do this, double-click each measure column in the fact table to
display the Logical Column dialog box, select the Aggregation tab, and then select the
required aggregation type from the Default Aggregation Rule drop-down list.
Alternatively, if you wish to set the same default aggregation rule for a set of logical
columns, CTRL-click all of the logical columns to select them, and then right-click and
select Set Aggregation. When the Aggregation dialog box is displayed, select the
default aggregation that you wish to apply to the logical columns. You can also uncheck
the All Columns The Same check box if you wish to set different default aggregation
types for the columns that you selected.
To change the order in which columns are listed within a logical table, right-click it and select
Properties (or just double-click the logical table to display the Properties dialog box), ensure
that the General tab is selected, click the logical column you wish to move, and then use the
Move Up and Move Down arrow buttons.
1.Similarly, if you wish to sort one logical column using the values in another (for
example, sort a column containing months in the format Feb-2010 by a column
containing months in the format 201002), double-click the logical column to display the
Logical Column dialog box. Then, using the Set button next to the Sort Order Column
area, select the column you wish to sort this one by.
right-click the business model for which you wish to create a logical dimension. Select
New Object | Logical Dimension | Dimension With Level-Based Hierarchy.
Note If the option to create a logical dimension is not shown, check that you have created
logical joins between your logical tables, as this option only becomes available when
you have logical dimension tables identified that do not otherwise have logical
dimensions defined for them.
2.When the Logical Dimension dialog box is shown, type in the dimension name (for
example, Products). Ignore the other options on this dialog box for the moment, and we
will look in detail at these later on in this chapter.
3.Now you will create the levels in the level-based hierarchy for this logical dimension.
Select the logical dimension that you have just created, right-click it, select New Object
| Logical Level, and the Logical Level dialog box will be shown. This first level will be
the “grand total” level for your dimension’s hierarchy, so name it All <Dimension
Name> (for example, All Products), and select the Grand Total Level check box.
4.Right-click this grand total level and select New Object | Child Level. Using the
Logical Level dialog box, type in the name of the level, and then when the dialog box
closes, right-click this level and repeat this step, creating levels under each other to
form the level-based hierarchy.
Now that you have created the levels, the next step is to associate logical columns with the
levels. To do this, drag-and-drop columns from the logical table associated with the dimension
onto the relevant level, and then right-click the column and select New Logical Level Key.
… Repeat this step for all of the levels in the logical dimension apart from the grand total
level.
Ensure that each logical column that you set as a logical level key does, in fact, contain
unique values; otherwise, the Oracle BI Server may provide incorrect results for a query. In
cases where you have an ID and a descriptive value for a dimension level (for example,
Product ID and Product Name), if just the ID is unique, drag both values into the logical level
but set just the ID as the level key. If both the ID column and the descriptive column are
unique, you can set both columns as level keys, and then select the descriptive column for
display during drill-down by right-clicking the logical level, selecting the Keys tab, and
checking the Use For Display check box for just the key containing the descriptive column.
This will be used when drilling down in the front end as the column to be displayed.
Some dimensions can contain more than one hierarchy. For example, a logical time
dimension may need to aggregate data through a calendar hierarchy and a fiscal hierarchy. In
these situations, all of the hierarchies will share a common top (grand total) and bottom (leaf)
level, but in between they will contain their own levels organized into alternate hierarchies. To
create a dimension with two alternative hierarchies, follow these steps:
1.Create the new logical dimension as before, and create a grand total level directly
under the logical dimension, naming it, for example, All Times. Ensure you select the
Grand Total Level check box when you create the level. (Note that it is not mandatory
to create a grand total level, but it is considered “best practice.”)
2.Start by creating the first hierarchy. Right-click the grand total level and create, one
by one, the child levels under it, until you reach the bottom (leaf) level.
3.Now return to the grand total level, right-click it, and select New Object | Child Level.
Continue now creating the levels under this alternative hierarchy, until you reach the
level just above the leaf level.
4.To join this alternative hierarchy back to the main one at the leaf level, right-click the
last level you created in the alternative hierarchy and select New Object | Shared Level
As Child. Then select the leaf (bottom) level from the list of levels so that this
alternative hierarchy is then joined back to the main one, at the leaf level.
5.Then, as before, drag-and-drop the logical columns from the related logical table onto
the levels, and create the logical level keys. You will only need to add the logical
column for the leaf level once, even though it is displayed as part of two separate
hierarchies under the logical dimension.
You may have noticed when creating your logical levels a setting labeled “Number of
elements at this level.” Best practice is for you to enter into this setting the number of unique
values (members) in the column designed as the level key. Providing this value is optional,
but when it is present it helps the BI Server determine the most optimal execution plan for a
query. You can either enter the number in manually or populate the values automatically when
the repository is open in online mode by right-clicking the logical dimension and selecting
Estimate Levels, which causes the BI Administration tool to run a series of queries on the
source database(s) to count the number of distinct values at each level. Note that the values
used in this setting need only be estimates, and you do not need to update them unless the
number of unique values in the associated logical column change significantly.
Having a presentation layer separate to the business model gives us an opportunity to create
a further level of abstraction away from the underlying data. We can, for example, split an
existing logical table into two or more presentation tables, or create presentation tables that
contain columns taken from more than one logical table. (Be careful, though, not to create
presentation tables that combine columns from logical tables that need to be joined via a fact
table before they can be displayed together.)
You can also “nest” one set of presentation tables within another to create a set of subfolders
under a master folder. In an example where you have a fact table containing both based
(physically mapped) and derived (calculated) measures, to place each set of measures in
their own folder, follow these steps:
1.Navigate to the presentation layer within your semantic model and locate the subject
area that you wish to work with.
2.Right-click the subject area and select New Presentation Table.
3.When the Presentation Table dialog box is shown, enter a name for the new
presentation table (for example, Base Facts), and within the Description area, type in –
> (a minus sign, followed by a greater-than sign). Repeat this step for any other
subfolders that you wish to create.
Drag-and-drop the columns that you wish to add to these subfolders, either from the existing
presentation table containing them in the subject area or from the corresponding business
model if you have not already dragged them to the presentation layer.
1.Finally, double-click the subject area you are working within the presentation layer,
select the Presentation Tables tab, and use the Move Up and Move Down buttons to
place the two subfolders under the presentation table that you wish to nest them under.
When you return to the main presentation layer view in the semantic model, you will see just
these two subfolders listed under the main folder. However, when you place the repository
online and view the list of folders within Oracle BI Answers, you will see folders nested and
with presentation columns listed under each subfolder.
Note This can also be done by putting a dash (–) in the name of the presentation table (for
example, – Base Facts)
To check consistency manually, again with the Oracle BI Administrator tool open, either select
a single object, right-click it and select Check Consistency, or select File | Check Global
Consistency from the menu to check all objects in the repository. If you receive the message
“Consistency check didn’t find any errors, warnings or best practice violations,” you are free to
move on to the last stage of the process. If not, either resolve the issue and recheck the
repository as before or mark the business model as unavailable and come back and resolve
any issues later on.
When you are first creating a repository, though, you may well end up with warnings or errors
reported by the consistency checker. Here are examples of some common warnings and
errors, and how to resolve them:
[39002] Level “Sales”.”Products”.”All Products” has no defined key to uniquely
identify members. If you get this warning for a level in a logical dimension hierarchy
that is the grand total (topmost) level, you have forgotten to check the Grand Total
Level check box for it. Go back and select this box, and the warning will go away. If the
level referenced in the warning is not the grand total level, though, this means that you
have forgotten to define the logical level key for it. Double-click the warning in the
consistency checker to go straight to this level, and then set the key to remove the
warning.
[39001] Logical table Dim Products has no defined key. This means that while you
have defined a logical table as a dimension table, you haven’t created the table key for
it. Double-click the warning row in the consistency checker, and use the Keys tab to set
the logical key.
[38018] Business model Sales does not have corresponding subject area. This
error is shown when you have defined a business area but not yet a corresponding
subject area in the presentation layer for it. Create the subject area as you would do
normally, and the error will go away.
After a few minutes, you should then see the message “Restart Selected – Completed
Successfully.” If you receive an error message, repeat steps 3–9, but check carefully that you
have entered the correct password; and if the process fails again, use the Consistency Check
Manager on the offline repository to check that there are no errors that are stopping the
Oracle BI Server from starting with this repository online.
Congratulations! Your repository is now online and ready for use. Now that you know the
basics, let’s take a look in more detail at what else you can do with the repository.
Functional Compensation
If the source database had less functionality, though (such as a Microsoft Access database),
the BI Server “compensates” for this by just requesting the raw information from the source
database, and the BI Server then performs the additional calculations in memory.
Taking this approach allows Oracle Business Intelligence to provide the same calculation
capabilities regardless of the data source, so users can create analyses spanning different
source database types without worrying which sources support which types of calculations. All
of this happens transparently to the end user, though as a developer you need to be aware of
the extraload this can place on both the source database (which potentially has to return a
larger set of raw data to the BI Server) and the BI Server (which has to perform what can be
quite complex calculations).
Should you now wish to calculate the average percentage margin for these sales as a new
logical column, there are two ways in which you could derive the calculation: you could base
the calculation on the revenue and profit logical column in the logical layer (a “post-
aggregation” calculation), or you could define the calculation directly in the logical table
source mapping, based on the physical columns (a “pre-aggregation” calculation), and
depending on which route you take, you’ll potentially get different numbers returned.
In this example, to create the logical column using a logical calculation, you would do the
following:
1.Using the Oracle BI Administration tool, right-click the fact table and select New
Object | Logical Column.
2.Using the Logical Column dialog box, select the General tab and give the column a
name; for example, Avg. Margin % (Logical).
3.Click the Column Source tab for this new column, and select “Derived from existing
columns using an expression” as the column source type.
4.Click the Edit Expression button to the right of this label. Then, using the Expression
Builder dialog box, enter the expression for the column source, such as (“Sales”.”Fact
Sales”.”Profit” / “Sales”.”Fact Sales”.”Revenue”) * 100.
5.Close the dialog box and copy the new logical column to the presentation layer of the
semantic model. Finally, save the repository, ensure it is online, and then create a test
analysis to view the results.
For the preceding data set, the average percentage margin for sales of bread assortments is
reported as 34.37, which has been calculated in the following way:
sum (all revenue) / sum (all profit) = % margin
You now create a second percentage margin logical column, but this time you’ll use a physical
calculation to perform it. To do this, follow these steps:
1.Using the Oracle BI Administration tool, right-click the fact table, and select New
Object | Logical Column.
2.Using the Logical Column dialog box, select the General tab and give the column a
name; for example, Avg. Margin % (Physical).
3.Click the Column Source tab for this new column, and select “Derived from physical
mappings” as the column source type.
4.Click the logical table source mapping under this option to select it, and click the Edit
button to edit the table source mapping and ensure that the Show Unmapped Columns
check box is selected.
5.With the Logical Table Source dialog box open, click the blank area next to the new
logical column, and click the Edit Expression button.
6.Using the Expression Builder dialog box, create the calculation; for example:
("orcl".."GCBC_SALES"."Fact_SALES"."PROFIT" /
"orcl".."GCBC_SALES"."Fact_SALES"."REV_AMT")
* 100
7.As this is a physical calculation derived using column mappings, you will need to set
the default aggregation type for the column. With the Logical Column dialog box still
open, switch to the Aggregation tab and set the default aggregation rule to Avg.
8.Again, close the dialog box and copy the new logical column to the presentation layer
of the semantic model. Then save the repository, ensure it is online, and create a test
analysis to view the results of this second query.
This time, the average percentage margin reported back is 33.84. So why do the two
numbers differ?
It has to do with where the percentage margin calculation is done. The logical calculation
sums up all the revenue figures and all the profit figures, and then calculates the percentage
margin based on dividing one total by another. The physical calculation, however, calculates
the percentage margin at a line level, and then averages these figures, giving a different
overall total to the logical calculation. So when you create calculations like these in your
business model, make sure that you do them consistently; also be aware that percentages
and other calculations can come out differently depending on the point at which you
aggregate your data.
Conversion Functions
Logical SQL comes with a number of conversion functions for converting between data types,
dealing with missing values, or performing Oracle BI–specific functions such as making use of
variables or switching between columns:
IFNULL (expr, value) This provides a value should the column contain a NULL (a
missing value) and is equivalent to Oracle’s NVL and other similar functions; for
example, IFNULL (company_name, ‘Allied Bakers’).
CAST (expr | NULL as data_type) This converts between two different data types,
converting, for example, string columns into dates using the expression CAST
(commence_date AS DATE).
VALUEOF (variable_name) This is unique to logical SQL and allows a calculation to
reference the value held in a repository variable; for example, VALUEOF
(NQSESSION.home_store) accesses the value contained within the repository session
variable home_store, which would typically be set using an initialization block at the
start of a new user session. There are various variable name formats that you need to
use, depending on the type of repository variable being used, all of which are detailed
later in this book.
INDEXCOL (integer, expr_list) This returns the column or expression in expr_list,
starting with 0 for the first entry in the list, based on the integer value passed to the
function. This function can be useful, for example, when you wish to dynamically select
a column from a list based on a value in a variable, allowing a single function to make
use of a set of columns with the particular column selected at query time. For example,
consider a situation where you wish to display data in either US dollars or UK pounds,
based on the currency code set for a user. For users who wish to display values in US
dollars, the session variable PREF_CURRENCY is set to 0, while for UK pounds it is
set to 1. You could then use the INDEXCOL function to display the correct currency
amount based on this variable:
INDEXCOL (VALUEOF(NQ_SESSION.pref_currency), usd_amount, gbp_amount)
CHOOSE (expr1, expr2, expr3 … exprN) This performs a similar function to
INDEXCOL but selects the column to be returned based on the first one in the list that
the user has permissions to view, rather than an index value. For example, if four
columns are defined that contain product data at total, category, type,
and product_name level, and users are only given permission to access those columns
appropriate to their role, the following function would return the first column in the list
that the user had permission to view:
CHOOSE (product_total, product_category, product_type, product_name)
This function is again useful for displaying one particular column for a user based on
the user’s role, this time based on security permissions rather than an index value
stored in a variable.
Time-Series Functions
Logical SQL has three time-series functions that allow you to calculate the value of a measure
a set number of periods ago, up to a particular period, or between two arbitrary periods. All of
these functions require you to create a “time dimension,” a logical dimension based on your
own calendar table that has one or more chronological keys defined.
A chronological key has to satisfy three requirements:
The members (values) in it must be sequential, with their own natural order and with
members equally spaced out.
The member list must be complete (that is, no missing months, days, and so on).
The Oracle BI Server then uses chronological keys to generate mathematically correct time
period predictions, working out, for example, that January, 2011 plus two periods would equal
March, 2011. Ideally, you will create chronological keys for each level in the time dimension,
but you can get by with just a chronological key at the bottom (leaf) level. If you perform a
time-series calculation at a hierarchy level that does not contain a chronological key, however,
the BI Server is forced to aggregate up from the next level down that does have such a key,
which can cause performance problems.
Earlier in this chapter we looked at how a logical dimension with a basic, balanced level-
based hierarchy was set up. Time dimensions are a variation on these types of dimension but
with additional metadata to assist with time-based calculations. Having a time dimension is a
prerequisite for performing time-series functions, so to set one up, follow these steps:
1. Ensure that you have a logical table within a business model that contains calendar
data columns (months, days, years, quarters, and so on), and that you have not
previously associated with a logical dimension.
2. Using the Oracle BI Administration tool, navigate to the business model within the
business model and mapping layer that contains the calendar logical table, right-click
the business model, and select New Object | Logical Dimension | Dimension With
Level-Based Hierarchy.
3. When the Logical Dimension dialog box is shown, type in the name (for example,
Times), and within the Structure section, select the Time check box.
Now create the levels within the hierarchy as you would do for a regular level-based logical
dimension, creating logical level keys for each level as usual. A typical hierarchy for a time
dimension would contain levels for all times, years, quarters, months, and days.
1.As you have created a time dimension, you now have to designate at least one of the
logical level keys as a chronological key, each of which must pass the three tests
described earlier. To define a chronological key, double-click the level for which you
wish to define the key, and when the Logical Level dialog box is shown, select the Keys
tab. Locate the key in the key list that you wish to designate as the chronological key,
and select the Chronological Key check box for it. You may have to scroll over to the
right to see this check box.
Repeat step 5 for any other chronological keys you wish to create for the time dimension.
Once you have defined at least one time dimension, you can then make use of Oracle
Business Intelligence’s time-series functions in your business model. These functions are
listed here:
AGO (expr, time_dimension_level, periodoffset) This is used for calculating the
value of a measure a set number of time dimension levels (periods) ago. For example,
this would calculate the value for revenue, one month ago:
Ago (“Sales”.”Fact Sales”.”Revenue” , “Sales”.”Times”.”Month” , 1)
Substitute other time dimension levels (ideally with chronological keys defined for
them) and numbers of offset periods for other time-offset calculations.
TODATE (expr, time_dimension_level) This is used for calculating the period to date
value for a measure; for example, year to date:
TODATE (“Sales”.”Fact Sales”.”Revenue” , “Sales”.”Times”.”Year”)
PERIODROLLING (measure, x, y [,hierarchy]) This is a new time-series function
introduced with the 11g release of Oracle Business Intelligence. It can be used to
calculate the value of a measure from offset x to offset y, with x typically being a
negative figure to indicate the past, and y being a number of periods on from x,
potentially into the future. The period (time dimension level) type is either inferred from
the period used in the analysis, or it can be specified by use of the AGGREGATE AT
function. For example, to calculate the value of revenue for the previous month, the
current month, and the next month, use the following formula:
PERIODROLLING (“Sales”.”Fact Sales”.”Revenue”, -1, 1)
The keyword UNBOUND can be used to specify all periods that are available, that is,
to the current period. For example, to calculate the value of revenue for the previous
six months to now (assuming no data exists beyond the current period), use the
following formula:
PERIODROLLING (“Sales”.”Fact Sales”.”Revenue”, -6, UNBOUND)
The optional hierarchy clause can be used to specify a particular hierarchy if the logical
dimension has more than one (for example, Times – Fiscal Year). For situations where
you wish to directly specify the dimension level to which to apply the PERIODROLLING
function, rather than infer it from the grain of the analysis, the AGGREGATE AT
function can be embedded within the PERIODROLLING function, like this:
PERIODROLLING (AGGREGATE(“Sales”.”Fact Sales”.”Revenue” AT quarter), -2,
UNBOUND)
Care should be taken with the use of time-series functions, as the Oracle BI Server can
generate quite complex and expensive SQL to return values using these functions. Because
regular database SQL cannot normally return data from two time periods simultaneously
using a single WHERE clause, the Oracle BI Server typically generates two or more queries
to retrieve data for all time periods, the result sets for which it then either joins together
internally in memory, or has the source database join if it has the capability to do so.
If you plan to make extensive use of time-series functions, consider using a multidimensional
database such as Oracle Essbase, which supports time-series functions natively and can
perform such calculations using far fewer database and system resources.
Lookup Functions
A new type of function introduced with the 11g release of Oracle Business Intelligence is the
lookup function. Lookups are a concept familiar to most BI and data loading developers,
andtypically they involve retrieving a descriptive value for a given ID value. You can do this
fairly simply in the Oracle BI Repository by editing a logical table source mapping using the
Add (+) button to add the physical tables to the table source mapping, and then using lookup
columns provided by the new mapped physical table to populate corresponding ones in the
logical table.
The lookup function introduced with Oracle Business Intelligence 11g is for a different
scenario, though, in which, for one reason or another, you wish to isolate one part of a query
from the main part.
There are two types of lookup functions that you can use in Oracle Business Intelligence 11g:
LOOKUP (DENSE (lookupColumn, commaSepExprs)) This is used for lookups
where you can be certain that a lookup value will be returned for every input value
(equivalent to an inner join in SQL).
LOOKUP (SPARSE (lookupColumn, alternateColumn, commaSepExprs)) This is
where you cannot be certain that you will always get a lookup value returned
(equivalent to a left outer join in SQL).
The LOOKUP function can also be used with both physical columns and logical columns
when used in conjunction with a logical table designed as a lookup table. Lookup tables are
just like regular logical tables; however, by designating them as lookup you remove the need
for them either to play the role of fact tables (with other tables joining to them) or dimension
tables (which join directly to fact tables).
To explain how the LOOKUP function works, let’s take a look at an example of the lookup
function in use, where we wish to perform a currency conversion.
When converting currency measures in a fact table from a base currency to a reporting
currency, a common approach is to create an exchange rate table in the physical layer, join
this table to the physical table containing the fact table measures in the logical fact table
source, drag the exchange rate to the logical fact table, and then multiply the base currency
with it to obtain the reporting currency amount. This converts base currency to reporting
currency successfully, but it has the disadvantage of including the join to the exchange rate
physical table into the main SQL GROUP BY clause, giving you a physical SQL query looking
like this log file excerpt:
WITH
SAWITH0 AS (select distinct T1114.EXCH_RATE as c1,
T1128.PROD_CAT_DESC as c2,
T1173.MONTH_YYYYMM as c3
from
GCBC_SALES.TIMES T1173,
GCBC_SALES.PRODUCTS T1128,
GCBC_MAILORDER_SALES.EXCHANGE_RATES T1114,
GCBC_MAILORDER_SALES.UK_MAILORDER_SALES T1120
where ( T1114.MONTH_YYYYMM = T1120.MONTH_YYYYMM ...
If it were possible instead to perform the main aggregation of the query as one step, and then
apply the exchange rates to the final, aggregated data set, your query might perform better
and use fewer database resources. This would be where you could use a dense lookup
function. By retrieving the exchange rate from either the physical exchange rate table or from
a logical lookup table, let’s say you use an expression such as the following, where the
Lkp_EXCHANGE_RATES table contains a single exchange rate between the base currency
and the reporting currency, keyed on the month and year:
This would instead result in a physical SQL query looking like the following excerpt:
WITH
SAWITH0 AS (select sum(T1120.LOC_REV_AMT) as c1,
T1128.PROD_CAT_DESC as c2,
T1173.MONTH_YYYYMM as c3
from
GCBC_SALES.TIMES T1173,
GCBC_SALES.PRODUCTS T1128,
GCBC_MAILORDER_SALES.UK_MAILORDER_SALES T1120
where ( T1120.MONTH_YYYYMM = T1173.MONTH_YYYYMM
and T1120.PROD_ID = T1128.PROD_ID )
group by T1128.PROD_CAT_DESC, T1173.MONTH_YYYYMM),
...
SAWITH2 AS (select T1114.EXCH_RATE as c1,
T1114.MONTH_YYYYMM as c2
from
GCBC_MAILORDER_SALES.EXCHANGE_RATES T1114),
As you will see, the access to the exchange rate table has now moved outside of the main
GROUP BY in the SQL query, potentially improving the efficiency of the query.
System Functions
In some situations you may wish to include the user’s login details in a query, perhaps to help
filter the data returned by the database. In others, you might want to return the name of the
default subject area. To do this, you can use the two following system functions that do not
have any arguments:
USER This returns the login name for a user.
DATABASE This returns then name of the default subject area.
Hierarchy Functions
There are also a number of functions introduced with the 11g release of Oracle Business
Intelligence that you cannot normally access through the repository or through your own
analyses in Oracle BI Answers but that are used by various parts of Oracle Business
Intelligence to traverse hierarchies, create hierarchical groups, and perform aggregations.
These include ISLEAF, ISPARENT, and ISDESCENDENT, and more details on these are
included in the product documentation; however, you would not normally use them yourself in
a column definition or Oracle BI Answers analysis.
The Calculation Wizard – Introduction dialog box will then be shown. Click Next to proceed.
1.The Calculation Wizard – Select Columns dialog box will then be shown. For every
column you select, the Calculation Wizard will then create a set of derived measures,
comparing them to the original logical column fact table measure. Select the
measure(s) that you wish to compare against the first measure (for example, Sale
Amount Month Ago), and click Next to proceed.
2.The Calculation Wizard – New Calculations dialog box will then be shown.
From the following list, select the calculations (derivations) that you wish to create:
Change This subtracts the second column from the first (for example, Sale
Amount – Sale Amount Month Ago).
Percent Change This subtracts the second column from the first and shows
the value as a percentage; for example: (100.0 * (Sale Amount – Sale Amount
Month Ago) / Sale Amount Month Ago).
Index This divides the first column by the second; for example: (1.0 * Sale
Amount / Sale Amount Target).
Percent This divides the first column by the second and expresses the result
as a percentage; for example: (100 * (Sale Amount / Sale Amount Target )).
2.Each of the preceding calculation types has special cases, such as when one of the
two numbers is missing, null, or above or below a certain value. For each calculation,
click it and use the panel on the left-hand side of the wizard to specify any special
handling for it.
3.Click Next, and then click Finish to complete the wizard. New calculations to match
your selections and special handling instructions will then be created in your business
model.
Each entry within the Sources folder represents a logical table source. A logical table source
is a set of mappings between logical columns in your business model and physical columns in
the physical layer of the semantic model. When you drag-and-drop columns from the physical
layer to a logical table, the Oracle BI Administration tool automatically creates the logical table
source for you, or you can create it yourself if you wish to create these mappings manually. In
cases where the physical tables you wish to map into the logical table are in fact part of a
physical database already mapped into the logical table via an existing logical table source, in
most cases you should extend the existing logical table source by editing it and adding it to
the existing logical table source mapping, but in some instances you will actually want to
create whole new logical table sources.
As an example, suppose that you have created a logical table called Fact Sales that is
primarily sourced from a physical (alias) table called Fact_SALES, within a physical database
and schema called orcl.GCBC_SALES. You create the outline (empty) logical table in the
business model and mapping layer and then add the columns by dragging and dropping
physical columns from the corresponding physical table to the logical Fact Sales table. If you
double-click the single entry under the Fact Sales Sources folder and select the Column
Mapping tab, you’ll see that it contains the column mappings between these two metadata
layers, as shown in Figure 3-16.
It is, however, possible to create more than one logical table source mapping for a logical
table. This situation occurs when, as described in more detail later in this chapter, you wish
to add additional logical columns to a logical table that are sourced from a second, separate
physical database, and you cannot of course just join these two tables together using a
traditional SQL join clause.
Instead, the Oracle BI Server will need to generate a second, separate physical SQL query to
obtain data from this second database’s table, and the BI Server then needs to join together
the two sets of returned queries before presenting the results back to the user using an
Oracle BI Server capability called “horizontal federation.”
Another reason that a logical table might have more than one logical table source is if the
same set of logical columns can be sourced from physical databases containing data of
differing levels of granularity. For example, the initial physical data source that you map in
may be at the lowest level of detail, such as with transaction-level data, while a second
source may contain the same data but pre-aggregated into a summary table or OLAP cube.
In this case, the summary-level table source would need to be configured to be used only by
the Oracle BI Server when the user requested an analysis at an appropriate level of
aggregation using a feature known as “vertical federation.” Figure 3-17 shows how these three
sets of logical table source column mappings then provide the Oracle BI Server with three
possible physical SQL statements that could be used to return data for a logical table, with the
Oracle BI Server choosing which ones to use based on the particular columns requested and
the level of detail requested by the analysis.
As mentioned, logical table sources can be configured to be used only when an analysis
requests data at a particular level of detail or aggregation, and this setting is controlled by
editing the table source properties and selecting the Content tab. This ability requires you to
define logical dimensions in your business model, and if this logical table source provides the
only source for a particular column and the user requests the column at a more detailed level
of granularity, the Oracle BI Server will return a NULL or an error for the column, depending
on what fact measures are chosen.
Typically, though, another table source will provide data at this lower level of detail, and the
Oracle BI Server will switch to this other table source when the user requires data at the lower
level of detail.
In addition to containing direct logical column to physical column mappings, logical table
source mappings can contain transformations (expressions) that use the same logical SQL
syntax used in logical column definitions. These transformations are often called “physical
calculations” and are performed before column data is aggregated, as opposed to after
column aggregation, as is the case with logical column calculations. See the section titled
“Logical and Physical Calculations” within the wider “How the Oracle BI Server Performs
Calculations” section for more details on this topic.
When you open a repository offline in this way, you are opening the repository in the
traditional binary format. You can, however, save and then open the repository in the MDX
XML format, which is typically used when checking a repository in, and out, of a source
control system. MDX XML format repositories, and integration with source control systems,
are covered in detail inChapter 11.
After you have selected the repository file to open, you are then prompted to enter the
repository password. The repository password secures the repository file, is set when you first
create the repository, and can be changed after you have successfully opened the repository
file from the Oracle BI Administration menu when the repository is accessed offline (File |
Change Password).
Note that, unlike the 10g release of Oracle Business Intelligence, you should not open
repository files directly by double-clicking them to open them directly within the Oracle BI
Administration tool, as this bypasses a script that the Oracle BI Administration tool requires to
configure various environment variables and will stop you from accessing physical database
sources. Instead, always start the Oracle BI Administration tool from the Windows Start menu
or run the script itself manually by calling the following command-line script (amending path
names for your particular environment):
C:\WINDOWS\system32\cmd.exe "/cC:\Middleware\instances\instance1\
bifoundation\OracleBIApplication\coreapplication\setup\bi-init.cmd
coreapplication_obis1 2 &&
C:\Middleware\Oracle_BI1\bifoundation\server\bin\
AdminTool.exe"
In addition to offline repository development, you can also connect online to a repository file.
In this case, you connect to the repository not directly to the file, but through an ODBC
connection to the Oracle BI Server, which in turn connects you to the default, online repository
for that Oracle BI Server. When you work with a repository file online, you check in and check
out repository objects as you work with them, and changes that you save are visible to users
once the Oracle BI Presentation Server’s copy of the repository has been refreshed and are
visible to other developers after they reconnect online to the repository.
To connect to a repository online, open the Oracle BI Administration tool and select File |
Open | Online from the application menu. You will then be presented with the Open Online
dialog box, into which you should enter the repository password and the connection details for
an account that has been granted the BI Administrator application role (or a comparable role if
you have created additional application policies).
When you connect to a repository online, other developers can also be connected online and
edit the same repository, checking in and checking out objects as they are edited. Oracle
Corporation states that best practice is for only a single developer to be working online with
each repository, as concurrent editing can cause performance issues for both developers and
users, although the 11g release of Oracle Business Intelligence does support up to
five developers working online at the same time (as opposed to a single developer in Oracle
Business Intelligence 10g). However, be careful when editing a repository online because
while the Oracle BI Administration tool tries to stop you from saving an invalid repository, if
you do manage to do so it may bring down the Oracle BI server and stop
other developers and users from working.
Editing a repository online does, however, give you access to a few functions that are not
available when working offline:
Managing scheduled jobs
Managing user sessions
Managing the query cache
Managing clustered servers
1. Note that this configuration file and others used by the BI Server component are
described in more detail in Chapter 5.
2. To make the Oracle BI Server start using your new repository, switch to the Availability
Processes tab and subtab within Fusion Middleware Control and navigate to the BI
Servers folder. Select the folder by clicking the box to the left of the folder name, and
click the Restart Selected button. Click Yes when prompted, and then check that the
activity completes successfully.
Note If the restart of the BI Server components does not complete successfully, check the log
files for the failure reason. In most cases, it is because you did not enter the correct
repository password or the repository is invalid and cannot be brought online.
Externalize Strings
For BI systems that are used by users in different regions, it can be useful to display table,
column, subject area, and hierarchy names from the presentation layer in the user’s particular
language. The externalize strings feature allows the administration to select particular
presentation layer objects and then either store names or descriptions for these objects in an
external file, which you can then populate with versions of these names and descriptions in
particular languages.
Setting up the externalize strings feature requires two steps:
1. First, select the presentation layer objects for which you wish to externalize names or
descriptions by right-clicking the object in the Oracle BI Administration presentation
layer and selecting either Externalize Display Names | Generate Custom Names or
Externalize Descriptions | Generate Custom Descriptions. Nothing will be displayed on
the screen when you make these selections, but the list of objects you have selected
will be recorded by the Oracle BI Administration tool for use later.
2. Once you have marked the presentation layer objects that you wish to externalize
strings for, run the Externalize Strings utility by selecting Tools | Utilities | Externalize
Strings from the Oracle BI Administration menu. When the Externalize Strings dialog
box is shown, select those subject areas that you wish to externalize into a file (you
can select them all or just single ones, with each one being externalized into a
separate file), and then click Save to save the externalized strings files.
Rename Wizard
When you create logical columns in your business model by dragging and dropping physical
columns, your logical columns inherit the physical column names. Physical column names are
often restricted by the source database to uppercase letters and may use underscores (_)
and other characters in the place of spaces. If you wish to replace these system-generated
logical column names with more user-friendly ones, you can either manually edit them
yourself or you can use the Rename Wizard to automatically rename them using rules that
you specify so that you can change, for example, a logical column name imported from your
physical layer as PRODUCT_NAME to instead be called Product Name.
To use the Rename Wizard, follow these steps:
1. Using the Oracle BI Administration menu, select Tools | Utilities | Rename Wizard.
2. Using the Rename Wizard – Select Objects dialog box, select either the presentation
layer objects or business model and mapping layer objects that you wish to rename.
Click the Add button to add just the selected object, or the Add Hierarchy button to add
the object plus all its dependent (child) objects.
3. On the Rename Wizard – Select Types screen, check or uncheck those object types
contained in the object set you selected that you wish to rename.
4. On the Rename Wizard – Select Rules screen, create the rules that you wish to apply
to your selected objects; for example, you may wish to capitalize all first letters, change
letters to lowercase, add spaces, or replace one character with another. Click the Up
and Down buttons to change the sequence in which the rules are applied.
5. Click Next to review the changes that will be applied, and then click Finish to make the
changes.
Repository Documentation
Given that there are three layers of object metadata in the repository, it is useful to be able to
generate a “lineage” report that shows how each presentation layer object is sourced through
the repository model, and equally how the removal or change of a physical layer object could
affect downstream objects in the repository. The Repository Documentation utility goes some
way to providing this lineage information, though it does not extend to Oracle BI Presentation
Server objects and really requires you to load this information into a database to make much
use of it.
To generate this repository documentation, take the following steps:
1. From the Oracle BI Administration menu, select Tools | Utilities | Repository
Documentation.
2. When prompted, select a file system location and document format to output to.
The Repository Documentation utility will then generate a file that, for each presentation layer
object, lists the presentation table, business model and mapping layer table and column, any
derivations, and the same for the corresponding physical layer objects and derivations. You
can then load this information into a relational database to track the lineage of your objects
and any changes to them over the development lifecycle.
When you select a subject area column or other object and click the Open Metadata
Dictionary button, your web browser will display a metadata report for the object in question.
Remove Unused Physical Objects
The Remove Unused Physical Objects utility can be used to remove physical tables, views,
and other objects from the semantic model if they are no longer present in the underlying data
source. Removing unused objects can be useful, as it reduces the size of the repository file
and consequently reduces the memory usage of the Oracle BI Server.
To use this utility, do the following:
1. Using the Oracle BI Administration tool, open your repository online or offline, and then
select Tools | Utilities | Remove Unused Physical Objects.
2. The Oracle BI Administration tool will then scan your data sources, as defined through
the physical layer of the Oracle BI Repository, and present you a list of candidate
objects to be removed.
3. Select the check box for any objects you wish to remove, and click the Yes button to
remove them from the repository.
Aggregate Persistence
The Aggregate Persistence Wizard can automate the production and population of aggregate
(summary) tables, which are then automatically mapped into your semantic model using the
vertical federation feature described later in this chapter. Aggregate tables can improve the
response time of your analyses through precomputing common aggregations, and the Oracle
BI Server will automatically make use of them when the analysis requests the appropriate
level of aggregation.
The Aggregate Persistence Wizard creates physical database tables, along with scripts, to
create indexes and then populate these tables. As with the parent-child relationship table
created by the Parent-Child Relationship Table Wizard, you run the table creation script first
and then rerun the population script every time the underlying data changes. As such, it is
best suited to scenarios where you control the loading of data into your system (for example,
a data warehouse) and can therefore trigger the calling of the aggregate table refresh routine
after each data load.
If you are using a database such as Oracle Database 10g Enterprise Edition or higher, you
might also want to consider having the database create your aggregate tables for you, in the
form of materialized views, which the database will then automatically use through a feature
called query rewrite. The Aggregate Persistence Wizard is therefore particularly well suited to
situations such as the following:
You are not able, or allowed, to create materialized views (or equivalent) in your source
database.
You wish to store the aggregates in a separate database to your main data set,
potentially using a different database type.
You are using, for example, the Standard Edition of the Oracle Database, and
advanced features such as materialized views are not available to you.
You wish to create aggregate tables for logical fact table mapping to multiple source
databases but store the aggregates in a single location.
To use the Aggregate Persistence Wizard, follow these steps:
1. Using the Oracle BI Administration tool, open your repository either online or offline.
Then, select Tools | Utilities | Aggregate Persistence from the application menu.
2. At the Aggregate Persistence – Select File Location dialog box, enter a complete path
and file to which the aggregate persistence scripts will be saved. Select the “Generate
DDL in a separate file” check box if you wish to generate the table creation script
separate to the table population script (normally they are combined into one), for
example, if you wish to amend this script before running it.
3. At the Aggregate Persistence – Select Business Measures dialog box, select the
business model, and then the fact table measures that you wish to aggregate.
4. At the Aggregate Persistence – Select Levels dialog box, select the logical dimension
levels at which you wish to aggregate these measures. Select the Use Surrogate Key?
check box only if the primary key for the logical level is a noninteger or extends over
several columns.
5. At the Aggregate Persistence – Select Connection Pool dialog box, select the physical
database, catalog/schema, and connection pool that connect to the physical database
where you wish to create the aggregate tables.
6. Click Next and then click Finish to create the aggregate table scripts.
At this point, while the scripts have been generated, you need to actually execute them to
create the aggregate tables and map them into the semantic model. Unlike the parent-child
relationship table scripts that you execute through your database command-line utility, the
scripts generated by this utility are executed by the Oracle BI Server so that it can also use
them to automatically map the tables into your repository’s physical layer.
To run the script(s), you need to use the nqcmd.exe utility, which can normally be found within
your Oracle BI installation, typically in the following location:
C:\Middleware\Oracle_BI1\bifoundation\server\bin\nqcmd.exe
Before you run this command, though, you must run the initialization command file, bi-
init.cmd, typically found here:
C:\Middleware\instances\instance1\bifoundation\OracleBIApplication\coreapplication\setup\bi-
init.cmd
The nqcmd.exe utility is run from the command shell launched from this command file.
The repository to which you wish to deploy the aggregates needs to be online when you run
this utility. To run nqcmd.exe, you must supply five parameters:
The ODBC DSN name for the connection to the BI Server hosting the repository (for
example, coreapplication_OH1094451294)
A username and password (for example, weblogic/welcome1) that connects to Oracle
Business Intelligence and that has the BIAdministrator (or equivalent) application role
granted to it
The name of the input file, which will be the name of the file just generated by the
Aggregate Persistence utility
The name of an output file to which to output the results of the command
You should also enable query logging for this user so that you can see if any queries have
failed or exited abnormally.
For example, to run the nqcmd.exe utility for your script, you might run the following
command:
C:\Middleware\Oracle_BI1\bifoundation\server\bin\nqcmd.exe -d
coreapplica-
tion_OH1094451294 -u weblogic -p welcome1 -s c:\files\agg_wiz.txt -o
c:\files\
agg_wiz_output.txt
Your aggregate tables will then be generated and automatically mapped in your semantic
model.
Oracle Business Intelligence 11g allows you to create logical dimensions with both ragged
and skip-level hierarchies, though care should be taken with these as they can have
performance implications in some cases.
In the example in Figure 3-19, a physical table called STORES_RAGGED has been defined
that contains columns for each level in the hierarchy, together with a surrogate (synthetic) key
that links the table to a fact table called SALES. Figure 3-19 shows the table, as displayed in
Oracle SQL*Developer, with the columns that we will use for the logical dimension.
Note how some rows feature concession IDs and descriptions that are null; these represent
either stores with no concessions linked to them or a single record for a store that does have
a concession for the purposes of recording sales specifically against the store. One other row
features a concession but not a store; this is a skip-level member and represents a
concession that reports directly into the regional office. Finally, if you are working with ragged
and/or skip-level hierarchies, you will need to ensure that all of the levels for your hierarchy
are contained in a single table, rather than in normalized, snowflaked tables, as the ID
columns that would normally contain level keys may in fact contain NULL values and are
therefore not valid as keys.
To create a ragged and skip-level hierarchy that uses this physical table as a source, follow
these steps, which are the same as for creating a balanced, level-based hierarchy, apart from
marking the hierarchy as ragged and/or skip-level:
1.Using the Oracle BI Administration tool, ensure that the physical table containing the
data for your ragged/skip-level hierarchy is present in the physical layer of the semantic
model, that the table is aliased, and that you have defined a key for the physical table
(based on the STORE_PK column in the example we are using). Then, using this key,
create a physical join between this table and the fact table it is associated with.
2.Within your business model, create a logical table to correspond with the physical
dimension table, ensure that you have defined a logical key for it, and create a join
between this logical table and your logical fact table. So far, this process has been
identical to how you would prepare your business model for a regular balanced, level-
based hierarchy.
3.To create the logical dimension that will contain the ragged and skip-level hierarchy,
right-click the business model containing the logical table you just created and select
New Object | Logical Dimension | Dimension With Level-Based Hierarchy.
4.When the Logical Dimension dialog box is shown, within the Structure area select the
Ragged check box if the hierarchy is ragged and the Skipped Levels check box if the
hierarchy features skip levels. Note that you can select both of these boxes if required,
but these options are grayed out and unavailable if you first select the Time check box,
as time dimensions must have balanced hierarchies.
Now, as you did for the balanced hierarchy earlier in this chapter, right-click the new logical
dimension and select New Object | Logical Level. This will be your grand total level, so name
it appropriately and select the Grand Total Level check box.
1.Now, as with balanced, level-based hierarchies, right-click the grand total level and
select New Object | Child Level. Name the level, enter the estimated number of distinct
members at this level, and then repeat this step to create the remainder of the level,
down to the concession level in the case of our example.
2.Drag-and-drop columns from the dimension logical table onto the levels that you just
created, right-click them, and select New Logical Level Key to create the level keys.
3.Finally, drag-and-drop the logical dimension table (not the hierarchy) to your
corresponding subject area in the presentation layer. Your hierarchy and logical table
are now ready for use within an analysis.
If you have query logging (described later in this chapter in the section “How Does the Oracle BI
Server Handle Vertically Federated Data?”) enabled for this account and you examine the
physical SQL generated for the analysis, an excerpt of the SQL would look like this:
WITH
SAWITH0 AS (select distinct sum(T71.FCAST_SAL_AMT) as c1
from
SALES T71 /* Fact_SALES */ ),
SAWITH1 AS (select sum(T71.FCAST_SAL_AMT) as c1,
T52.PROD_CAT_DESC as c2
from
PRODUCTS T52 /* Dim_PRODUCTS */ ,
SALES T71 /* Fact_SALES */
where ( T52.PROD_ID = T71.FCAST_COST_AMT )
group by T52.PROD_CAT_DESC),…
Note how only those columns required for the query are included in the WHERE clause and
only a regular GROUP BY is used to provide the aggregation.
If we now create a similar analysis involving the ragged and skip-level hierarchy, the resulting
pivot table would look the same, as there are no ragged members or skip levels at this point
in the hierarchy.
However, if you examine the physical SQL generated by the query, you will note how, in this
instance, all of the levels and therefore columns in the hierarchy are included in the query and
how GROUPING_ID / GROUPING_SETS has been used to provide the aggregations:
WITH
SACOMMON26514 AS (select sum(T71.FCAST_SAL_AMT) as c1,
max(T414.REGION_NAME) as c2,
max(T414.CONCESSION_NAME) as c3,
max(T414.STORE_NAME) as c4,
T414.REGION_NAME as c5,
T414.STORE_NAME as c6,
T414.CONCESSION_NAME as c7,
grouping_id(T414.REGION_NAME,
T414.STORE_NAME,
T414.CONCESSION_NAME) as c8
from
STORES_RAGGED T414 /* Dim_STORES_RAGGED */ ,
SALES T71 /* Fact_SALES */
where ( T71.STORE_ID = T414.STORE_PK )
group by grouping sets (
(),
(T414.REGION_NAME),
(T414.STORE_NAME, T414.REGION_NAME),
(T414.CONCESSION_NAME, T414.STORE_NAME, T414.REGION_NAME))),
…
GROUPING_ID and GROUPING_SETS are used across all level-based hierarchies when
hierarchical columns are used in a pivot table and when the analysis requires subtotals and
totals across multiple hierarchies in levels. They are used much earlier in ragged and skip-
level hierarchies, however, because for the following reasons the Oracle BI Presentation
Server has to consider more than just the immediate levels selected for analysis:
A member being displayed may in fact be a ragged member, and the Presentation
Server will need to indicate that no more drilling to detail can be performed on that
branch of the hierarchy.
A particular hierarchy branch may feature a skip level, and therefore members from the
lower levels in the hierarchy may need to be displayed if its parent is skipped in the
level being displayed.
This means that, in practice, when an analysis uses a ragged or skip-level hierarchy, all of the
levels and columns for a query will be included in the physical SQL to retrieve that hierarchy’s
columns from the database, and results will be aggregated across all of these levels to deal
with these situations. Therefore, you may find that queries using ragged and skip-level
hierarchies generate more expensive database queries than those with balanced, level-based
hierarchies, so you should reserve use of this feature for those logical dimensions that
actually feature ragged or skip-level hierarchies.
Parent-Child Hierarchies
In addition to supporting ragged and skip-level hierarchies, the 11g release of Oracle
Business Intelligence now also supports parent-child, or value-based, hierarchies. Instead of
having the hierarchy defined by separate columns in the database, one for each level, parent-
child hierarchies define the hierarchy through a member ID and a parent ID, with the parent
ID recursively joining back to the member ID.
Consider a situation where we have a STAFF_PARENT_CHILD table in the physical layer of
the semantic model, as shown in Figure 3-20, that features five columns:
STAFF ID This is the key for the table and ID for individual staff members.
STAFF_NAME This is the descriptive column for the staff member.
STAFF_GENDER and STAFF_DOB These are attributes for the staff member.
MANAGER_ID This is a column that references the STAFF_ID column and contains
the staff ID for the staff member’s manager.
This type of table and hierarchy can be modeled within the Oracle Business Intelligence
11g semantic model. To assist with using it in analyses, a parent-child relationship table, or
“closure” table, is generated for you by the Oracle BI Administration tool when defining the
hierarchy. This parent-child relationship table then has to be maintained by you, using a
supplied SQL script whenever the underlying data in the dimension physical table changes.
To create a logical dimension with a parent-child hierarchy, follow these steps:
1.Using the Oracle BI Administration tool, select File | Import Metadata to import the
physical table metadata for the source table into the semantic model, create an alias
for it (for example, Dim_STAFF_PARENT_CHILD) and create a table key. Ensure that
there is no foreign key defined for this physical table from the Parent ID to the Member
ID column, as this may raise warnings from the consistency checker. Then, using the
dimension table key, create a physical join between this table and the fact table it is
associated with.
2.Within your business model, create a logical table to correspond with the physical
dimension table, ensure that you have defined a logical key for it, and create a join
between this logical table and your logical fact table. So far, this process has been
identical to how you would prepare your business model for a regular balanced, level-
based hierarchy.
3.To create the logical dimension that will contain the parent-child hierarchy, right-click
the business model containing the logical table you just created, and select New Object
Logical Dimension | Dimension With Parent-Child Hierarchy.
4.The Logical Dimension dialog box will then be shown. Check and update if necessary
the name chosen for the hierarchy, and check that the Member Key column is set to
the primary key for the logical table (the default setting). Then, using the Browse button
next to the Parent Column text box, select the parent ID (for example, Manager ID) for
this parent-child hierarchy.
With the Logical Dimension dialog box still open, click the Parent-Child Settings button to
create the parent-child relationship table. The Parent-Child Relationship Table Settings dialog
box will then be displayed.
1.With the Parent-Child Relationship Table Settings dialog box open, highlight the row
for your logical table and click the Create Parent-Child Relationship Table button to the
right of it (the middle button in the list of buttons, with a “new table” icon).
2.The Generate Parent-Child Relationship Table Wizard will then open. Type in a name
and file system location for the DDL Script To Create Parent-Child Relationship Table
and DDL Script To Populate Parent-Child Relationship Table settings. Note that the
wizard will not let you progress to the next screen unless the file system directory you
specify actually exists.
3.On the next screen of the wizard, type in a name for the table (for example,
STAFF_CLOSURE) and select the connection pool that corresponds with the physical
database that you intend to store the parent-child relationship table in. Once the wizard
completes, this physical database within your semantic model will be updated to
include the parent-child relationship table that you are now creating.
4.Review the scripts that the wizard will create for you, and click the Finish button to
create the scripts and place them in the file system location you specified. You will then
return to the Parent-Child Relationship Table Settings dialog box. Click OK to return to
the Logical Dimension dialog box, and click OK again to return to the main Oracle BI
Administration screen.
Now you have to run the two scripts generated by the previous steps. To do this, start a
command-line prompt for your database so that you can run the scripts. For example, if you
are using an Oracle database, select Run from your Windows Start menu, type
in cmd.exe, and then enter the following commands (assuming that you have saved the
scripts to the c:\files directory, you have chosen to store the closure table in the
GCBC_SALES/password schema, and your TNSNAMES net service name is ″ORCL″:
cd c:\files
sqlplus gcbc_sales/password@orcl
@create_closure_table.sql
@pop_closure_table.sql
commit;
1.Drag-and-drop the logical dimension table to the subject area within your
presentation layer containing the other data for your business model. Save your
repository, and use the consistency checker to ensure that there are no warnings or
errors for the repository.
If you take a look at the logical dimension created by the Oracle BI Administration tool, you
will notice that it has two levels within the hierarchy, one for the grand total level and one for
the detail level, containing all of the keys and attributes for the logical dimension table. The
presentation hierarchy within the subject area presentation table has just a single entry to
show that when it is to be included in an analysis you work with just a single object that
recursively drills into itself.
This is not, however, the behavior for level-based hierarchies, where each member’s total is
equal to the sum of the lower-most leaf levels in the hierarchy that roll up (aggregate) into that
member. The reason for this is due to how the parent-child relationship table is included into
the physical layer when it is created by the Oracle BI Administration tool.
If you select the dimension table, fact table, and parent-child relationship table within the
physical model, right-click them and select Physical Diagram | Selected Object(s) Only, you
will see that the parent-child relationship table is not, by default, joined to either the dimension
table or the fact table. Instead, the fact table joins to the dimension table only, or in this
instance the STAFF_ID column, which is why the Oracle BI Server only includes values for
that particular staff member when calculating the total for each staff member.
To ensure that the Oracle BI Server includes the dimension member’s descendents in its total,
and therefore that values aggregate up the hierarchy, you have to modify the physical layer
joins to include the parent-child relationship table. To do this, follow these steps:
1.Using the Oracle BI Administration tool, open your repository offline and then
navigate to the physical layer of the semantic model; then, right-click the physical
dimension table, fact table, and parent-child relationship table for your parent-child
hierarchy, and select Physical Diagram | Selected Object(s) Only.
2.With the Physical Diagram screen open, check that the physical dimension table
joins directly to the physical fact table and that the parent-child relationship table is not
included in the join (as per the previous screenshot).
3.Click the join between the physical dimension table and physical fact table, and then
right-click and select Delete.
4.With the New Join button selected, draw a join starting at the fact table and ending at
the parent-child relationship table. When prompted to specify the join columns, select
the MEMBER_KEY column from the parent-child relationship table and the dimension
key column (for example, STAFF_ID) from the fact table.
5.Repeat step 4, but this time create a join between the parent-child relationship table
and the dimension table, joining the key column from the dimension table (for example,
STAFF_ID) to the ANCESTOR_KEY column in the parent-child relationship table. Your
physical diagram should now look like this:
As there is now no direct link between the dimension physical table and the fact physical
table, you will need to include the parent-child relationship table in the logical table source
used by the parent-child hierarchy’s logical table. To do this, navigate to the business model
and mapping layer in the semantic model, locate the parent-child dimension’s logical table,
expand the Sources folder, and double-click the table source to edit it.
1.With the Logical Table Source dialog box open, select the General tab to display the
list of mapped tables (currently just the physical dimension table). Click the Add button,
and then select the parent-child relationship table to add it to the table list.
2.To save the repository, select File | Save. The Consistency Check Manager dialog
box will then be displayed and will show a warning that the logical table source you just
edited contains columns not used in any column mappings. You can ignore this
warning, as it just refers to the parent-child relationship table that you needed to map in
to create the link between the fact and dimension table sources.
3.Click Close to close this dialog box, save your repository to the file system, and then
use Fusion Middleware Control to make this repository the default, online repository.
If you then display the parent-child hierarchical column in an analysis, along with a measure,
you will see that the total for each member now includes aggregated values for that member’s
descendants added to the value associated with that individual member.
Displaying Hierarchy Members When No Measure Values Are Associated (Left Outer
Joins)
If you display any type of hierarchical column in an analysis on its own, all of the members will
be displayed when you drill into the analysis. If, however, you include measures from a fact
table into the analysis criteria, only those members with corresponding values in the fact table
will be displayed, due to the inner join that is created by default between the two tables in the
business model and mapping layer of the semantic model.
If you change this logical join to a left outer join instead, all rows from the logical dimension
table will be returned when you include the hierarchy in an analysis, even if there is no fact
table data associated with the measure. Make this change with caution, though, as it will
affect all analyses that use this dimension table and can cause existing analyses to return
incorrect or different data than before.
To alter your business model to use a left outer join between a dimension and a fact table,
follow these steps:
1.With your repository open in the Oracle BI Administration tool, navigate to the
business model containing the logical dimension and fact table. Locate the two tables,
right-click them, and select Business Model Diagram | Selected Tables Only.
2.The Business Model Diagram screen will then be displayed. Double-click the join
between the two tables to display the Logical Join dialog box. Within the Logical Join
dialog box, locate the Type drop-down list. Change the selected value from Inner to
Left Outer, and click OK to save the change. Save your repository as usual, and then
take your repository online, using Fusion Middleware Control if you have been working
offline with it.
When you next query the hierarchy, you will see that dimension members are displayed
regardless of whether fact table data is associated with them.
When measures from the two fact tables are included in an analysis, along with attributes
from one or more of the logical dimensions, the Oracle BI Server internally generates two
logical queries, one for each of the fact tables. This is to avoid what is called a “fan trap” error,
where SQL would otherwise double-count measures from the fact tables when joining through
a common dimension. Where possible, though, the Oracle BI Server will try to join these two
logical queries together into a single physical SQL, using what is called subquery factoring.
The physical Oracle Database 11g Enterprise Edition SQL shown here, resulting from a query
against the business model in the preceding section, shows how this would look in practice:
WITH
SAWITH0 AS (select avg(T616.SAT_SCORE) as c1,
T414.REGION_NAME as c2,
T62.MONTH_YYYYMM as c3
from
GCBC_SALES.STORES_RAGGED T414 /* Dim_STORES_RAGGED */ ,
GCBC_SALES.TIMES T62 /* Dim_TIMES */ ,
GCBC_SURVEYS.CUSTOMER_SATISFACTION T616 /*
Fact_CUSTOMER_SATISFACTION */
where ( T62.MONTH_YYYYMM = T616.MONTH_YYYYMM
and T414.STORE_PK = T616.STORE_PK )
group by T62.MONTH_YYYYMM, T414.REGION_NAME),
SAWITH1 AS (select sum(T71.FCAST_SAL_AMT) as c1,
T414.REGION_NAME as c2,
T62.MONTH_YYYYMM as c3
from
GCBC_SALES.STORES_RAGGED T414 /* Dim_STORES_RAGGED */ ,
GCBC_SALES.TIMES T62 /* Dim_TIMES */ ,
GCBC_SALES.SALES T71 /* Fact_SALES */
where ( T62.MONTH_YYYYMM = T71.MONTH_YYYYMM
and T71.STORE_ID = T414.STORE_PK )
group by T62.MONTH_YYYYMM, T414.REGION_NAME),
SAWITH2 AS (select D1.c1 as c1,
D1.c2 as c2,
D1.c3 as c3,
D1.c4 as c4,
D1.c5 as c5
from
(select 0 as c1,
case when D2.c2 is not null then D2.c2
when D1.c2 is not null then D1.c2 end
as c2,
case when D1.c3 is not null then D1.c3
when D2.c3 is not null then D2.c3 end
as c3,
D1.c1 as c4,
D2.c1 as c5,
ROW_NUMBER() OVER (PARTITION BY case
when D1.c3 is not null then D1.c3
when D2.c3 is not null then D2.c3 end ,
case when D2.c2 is not null then D2.c2
when D1.c2 is not null then D1.c2 end
ORDER BY
case when D1.c3 is not null then D1.c3
when D2.c3 is not null then D2.c3 end ASC,
case when D2.c2 is not null then D2.c2
when D1.c2 is not null then D1.c2 end ASC) as c6
from
SAWITH0 D1 full outer join
SAWITH1 D2 On D1.c3 = D2.c3
and nvl(D1.c2 , 'q') = nvl(D2.c2 , 'q')
and nvl(D1.c2 , 'z') = nvl(D2.c2 , 'z')
) D1
where ( D1.c6 = 1 ) )
select D1.c1 as c1,
D1.c2 as c2,
D1.c3 as c3,
D1.c4 as c4,
D1.c5 as c5
from
SAWITH2 D1
order by c1, c2, c3 NULLS FIRST
Notice the two WITH blocks at the start of the query (this is subquery factoring) and the full
outer join at the end of the query, where the Oracle BI Server realizes that it can “push” the
joining of these two separate logical queries into a single physical SQL statement; if we were
working with a database such as Microsoft Access or mySQL, where subquery factoring is not
available, two separate physical SQL queries would have been issued and the Oracle BI
Server would perform a full outer join, or stitch join, in its memory instead.
A similar situation would occur if it was just a dimension table that was being horizontally
federated from a new physical data source; if the new data source came from the same
physical database as the rest of the user’s analysis, the Oracle BI Server would push the join
down to the physical database, by including it and the full set of tables in the physical SQL. If,
however, the new physical dimension table came from a different database, two separate
queries would be issued for the two data sources and the Oracle BI Server would join the
resulting data sets in memory before passing the results back to the Oracle BI Presentation
Server.
What if, however, you specifically still want to return results from this fact table, even if an
unconfirmed dimension is included in the analysis criteria? Well, this approach is not
reallyadvisable because, as you will see, it returns repeated values for the measure in
question, but if you understand how the results will look, these are the steps you should carry
out:
1.Ensure that all of the logical dimension tables that you will include in the query have
logical dimensions and hierarchies defined for them, as we have with the Dim Products
logical table and its corresponding logical dimension.
Within the business model, locate the logical columns that you wish to display values for even
when the unconfirmed dimension is included in the analysis. Double-click the logical column
to display the logical column Properties dialog box, and then select the Levels tab.
1.With the Levels tab selected for those dimensions that do not ordinarily join to the
logical fact table containing the logical column (Product, in this example), set the
Logical Level to the grand total level for that logical dimension’s hierarchy.
Save your repository in the normal way, and check the repository’s consistency as usual.
1.Now rerun the analysis that you created earlier and note how, for the column you just
changed, values now appear for the measure, but these are in fact repeated across all
of the rows from the unconfirmed dimension.
This type of repository modeling is useful when, for example, you cannot use database-
specific features such as Oracle materialized views to handle pre-aggregation at the physical
database level or where you wish to store aggregated values in a different physical database
than the one storing your detail-level data. In addition, as previously mentioned and as
covered in Chapter 4, it is also a useful technique for when you wish to combine relational and
multidimensional data sources into a single business model.
To see how this works in practice, let’s work through an example where we map some
aggregate tables into an existing logical business model and configure the new logical table
sources so that the Oracle BI Server uses them when analyses request the required level of
aggregation.
Example: Vertical Federation Using Relational Data Sources
In this scenario, we have a semantic model containing a single logical fact table that contains
sales data that is then dimensioned by product, store, times, and staff logical dimension
tables. We now wish to introduce a second data source, this time containing summary-level
data for this same logical fact table, which we intend to map in using the vertical federation
feature.
At the start of the process, the business model and corresponding physical layer looks as in
the following screenshot. Note the existing detail-level logical table sources under each logical
table’s Sources folder and the single physical schema holding their corresponding physical
table sources.
To incorporate the aggregated data using vertical federation, follow these steps:
1.Using the Oracle BI Administration tool, connect to the aggregated data source, for
example, the GCBC_AGGS schema that comes with the sample data that
accompanies this book. Import the objects into the physical layer of the semantic mode
and then alias the tables as required, and then create keys and foreign key joins
between just the tables in this physical schema. In the example we are using, three
tables are imported: A_PROD_CATEGORIES, which contains product category data;
A_TIMES_QUARTERS, which contains quarters and year information; and
A_SALES_AGG, which contains sales data aggregated to the product category and
quarters levels.
Unlike horizontal federation, you do not create physical foreign key joins between the new
physical data source tables and the existing ones. Instead, you define the links between the
detail- and aggregate-level data sources by creating additional table sources for individual
logical columns within your business model. Starting with the aggregated physical dimension
tables, locate a physical column that has a corresponding logical column in the business
model you wish to vertically federate into. For example, the Dim_A_PROD_CATEGORIES
alias table (based on the A_PROD_CATEGORIES physical table) has a physical column
called PROD_CAT_DESC that corresponds to the Dim Products Product Category logical
column in our business model. Drag-and-drop this physical column onto the corresponding
logical column to create the join.
If you now navigate to the logical table and column that you just dragged the aggregate-level
physical column to, you will notice two things: first, a new logical table source has been added
to the Sources folder for this logical table, and second, if you double-click the logical column
and select the Column Source tab, you will see that this logical column now has two possible
table sources that can be used to return values for it.
Now you should set the logical level for the logical table source created by your previous
mapping step. Navigate to the Sources folder under the logical table you just mapped the
physical column into and double-click the logical table source that corresponds to your
aggregated data source. With the Logical Table Source dialog box open, select the Content
tab. For a dimension logical table, only one logical dimension should be listed under this tab,
which will correspond to this logical table. Use the Logical Level drop-down list to select the
hierarchy level that this source should be used at (for example, Product Category).
Repeat step 4 for any other columns in the incoming aggregated table source, and then do
the same for any other dimension physical tables in the new data source.
1.Now do this for the physical fact table in the presentation layer, mapping in the
aggregated physical columns to connect to the existing logical columns in your logical
fact table. When setting the aggregation level for the logical fact table aggregated table
source, you will need to specify levels for all of the relevant dimensions, and some of
the dimension levels will need to be left blank if the aggregated source does not
contain aggregate data for these dimensions.
2.Once complete, save your repository and check its consistency. As you have not
created any new logical columns, you do not need to make any further changes to the
presentation layer of your repository.
Note When performing a consistency check, you may get an error along the lines of “Table
Dim Products is functionally dependent upon level Product Category, but a more
detailed child level has associated columns from that same table or a more detailed
table.” If so, check to see whether the dragging and dropping of your aggregate-level
physical column onto the logical table has created an additional logical key at the
aggregate level. If it has, delete the extra key and recheck consistency.
Other variations on this process include mapping a new column from the aggregated data
source, which provides an additional column for the logical table but only applies at this
aggregated level of detail. This is, in fact, a combination of vertical and horizontal federation,
which would require you to take steps similar to the preceding example, but you would need
to create a new, additional logical column and corresponding presentation column for the new
aggregate-only measure.
Once complete, your semantic model, with aggregated data sources mapped in, should look
similar to that shown in Figure 3-22.
Taking a look at the corresponding entry in the query log file, you can see that the Oracle BI
Server has used the aggregate tables imported from the GCBC_AGGS schema referenced in
the previous section’s example to return data for the analysis. This is because the semantic
model maps the corresponding logical table sources in at this level of aggregation, and the
Oracle BI Server therefore assumes that it will return data more efficiently than the alternative,
detail-level table source.
WITH
SAWITH0 AS (select sum(T926.FCAST_SAL_AMT) as c1,
T924.PROD_CAT_DESC as c2
from
GCBC_AGGS.A_PROD_CATEGORIES T924 /* Dim_A_PROD_CATEGORIES */ ,
GCBC_AGGS.A_SALES_AGG T926 /* Fact_A_SALES_AGG */
where ( T924.PROD_CAT_DESC = T926.PROD_CAT_DESC )
group by T924.PROD_CAT_DESC)
select distinct 0 as c1,
D1.c2 as c2,
D1.c1 as c3
from
SAWITH0 D1
order by c2
However, if you now click the Product Category column to drill down, like this
and check the corresponding query log entry, you will see that the Oracle BI Server now
switches to the detail-level table sources, pointing to the GCBC_SALES physical schema in
our example data set:
WITH
SAWITH0 AS (select sum(T71.FCAST_SAL_AMT) as c1,
T52.PROD_CAT_DESC as c2,
T52.PROD_TYPE_DESC as c3
from
GCBC_SALES.PRODUCTS T52 /* Dim_PRODUCTS */ ,
GCBC_SALES.SALES T71 /* Fact_SALES */
where ( T52.PROD_ID = T71.FCAST_COST_AMT )
group by T52.PROD_CAT_DESC, T52.PROD_TYPE_DESC)
select distinct 0 as c1,
D1.c2 as c2,
D1.c3 as c3,
D1.c1 as c4
from
SAWITH0 D1
order by c2, c3
In this way, the Oracle BI Server picks the most efficient table sources to satisfy a query,
based on the logical levels at which you mapped them into the business model, all
transparently to the end user.
Fragmentation
Fragmentation is the name for another repository feature for Oracle Business Intelligence that
makes it possible to combine specific multiple table sources for a particular logical table, all at
the same level of detail, with each fragment providing a particular discreet range of values.
For example, a logical table containing sales transactions may have two logical table sources
defined for it, one that provides transactions up until midnight yesterday (perhaps from a data
warehouse) and another that provides today’s transaction (from, for example, an operational
system).
To set up fragmentation, you need to consider the following:
Each fragmented table source requires an expression that defines the range of values
that it provides; for example, you may define a fragmentation clause that specifies that
the table source provides values from 01-JAN-2010 until 31-DEC-2011.
This fragmentation clause may reference a repository variable so it could specify that it
provides values up until midnight yesterday, for example.
Fragmented logical table sources must have valid physical joins to appropriate fact or
dimension physical tables so that if the Oracle BI Server switches to using the fragment
it can still join to appropriate physical fact and dimension table sources.
Fragmentation is defined using the Logical Table Source properties dialog box, under the
Content tab, as shown in Figure 3-23.
To specify the range of values that the fragmented table source provides, use the Expression
Builder to specify the required expression, and select the “This source should be combined
with other sources at this level” check box.
You can also make reference to a repository variable within the fragmentation clause, allowing
you to set up fragmentation so that, for example, a historical fragment provides data up until
yesterday, while the current fragment provides real-time data for today only.
Repeat step 2 to create the columns for the logical dimension tables so that each table in the
business model has logical columns defined and a corresponding logical table source. Create
logical keys for the dimension tables and use the Business Model Diagram tool to create
logical joins between the logical dimension tables and the logical fact table, as you would do
with a normal business model.
1.Double-click the logical table source for the logical fact table to display the Logical
Table Source properties dialog box. Click the Content tab and locate the Fragmentation
Content section headed. Click the Expression Builder button and use the Expression
Builder dialog box to create a suitable expression that defines the scope of the data
this initial table source contains; in this example, the initial table source provides data
up to June, 2010, so the expression becomes “Sales - Fragmented”.”Dim
Times”.”Month YYYYMM” <= 201006. Then select the check box under this text area
that reads “This source should be combined with other sources at this level.”
Now you can create the second logical table source for the fact table, which this time
references the second physical fact table that in this example contains measure data from
July, 2010 onward. To do this, navigate to the second physical fact table in the physical layer
and drag-and-drop its measure columns on top of the existing logical ones in the logical fact
table so that a second logical table source is added under the Sources folder.
1. As with the previous logical table source, use the Content tab under the Logical Table
Source dialog box to set the fragmentation content for the table source; in this
example, it will be set to “Sales - Fragmented”.”Dim Times”.”Month YYYYMM” >
201006. Ensure that the “This source should be combined with other sources at this
level” check box is selected, and then close the dialog box.
Note Ensure that there are no gaps or overlaps between the ranges covered by all of the
table sources in your fragmented tables.
6. This completes the process of working with fragmentation. Create your presentation
layer objects as usual, save and check the consistency of your repository, and then
take it online to see the effect of the fragmentation clause in action.
Now, when you create an analysis using this business model and restrict, for example, the
criteria to show only data for May, 2010, the Oracle BI Server uses just the
Fact_SALES_HISTORIC logical table source and the corresponding physical table to satisfy
the query, like this:
WITH
SAWITH0 AS (select distinct sum(T71.FCAST_REV_AMT) as c1
from
TIMES T82 /* Dim_TIMES */ ,
SALES_HISTORIC T71 /* Fact_SALES_HISTORIC */
where ( T71.MONTH_YYYYMM = T82.MONTH_YYYYMM
and T71.MONTH_YYYYMM = 201006
and T82.MONTH_YYYYMM = 201006 ) )
select distinct 0 as c1,
D1.c1 as c2
from
SAWITH0 D1
If the user queried a date that corresponded to the other physical fact table, a similar query
would be issued but would reference the other physical fact table instead.
However, if you create an analysis that requests data that spans both physical fact tables, you
will see both tables used in the physical SQL query, with a UNION ALL clause to combine the
two sets of data:
WITH
SAWITH0 AS ((select T71.FCAST_REV_AMT as c2
from
TIMES T82 /* Dim_TIMES */ ,
SALES_HISTORIC T71 /* Fact_SALES_HISTORIC */
where ( T71.MONTH_YYYYMM = T82.MONTH_YYYYMM
and T71.MONTH_YYYYMM between 201006 and 201010
and T82.MONTH_YYYYMM between 201006 and 201010 )
union all
select T60.FCAST_REV_AMT as c2
from
TIMES T82 /* Dim_TIMES */ ,
SALES_CURRENT T60 /* Fact_SALES_CURRENT */
where ( T60.MONTH_YYYYMM = T82.MONTH_YYYYMM
and T60.MONTH_YYYYMM between 201006 and 201010
and T82.MONTH_YYYYMM between 201006 and 201010 ) )),
SAWITH1 AS (select distinct sum(D3.c2) as c1
from
SAWITH0 D3)
select distinct 0 as c1,
D2.c1 as c2
from
SAWITH1 D2
Finally, in this particular example, a common set of physical dimension tables were able to be
used for both of the physical fact tables because they held all of the dimension member
details referenced by both fact tables. Often, though, each fragmented physical fact table will
come with its own set of reference dimension tables, and you will therefore have to model
both sets in the physical layer of the semantic layer and make sure that both sets of physical
fact tables have the correct join to their respective physical dimension tables. This would
mean that not only would the logical fact table in the business model have two logical table
sources, but the logical dimension tables would also need two as well, adding to the
complexity of your repository model.
Double Columns
Double columns, or descriptor ID support, describes a feature within Oracle Business
Intelligence 11g where an ID column can be assigned to a descriptive column. This can
sometimes be useful to help the underlying data source optimize its query and also provides
the ability to see the ID in the front end without giving the users direct access to the ID
column.
For example, you might assign an ID column to a descriptive column if the underlying physical
table is partitioned on the ID column and you wish for the ID to be used in the query predicate
rather than the descriptive column. As another example, you might want to create multiple
language translation columns for a dimension attribute column but have each of them use a
common ID column if used in a query.
To specify the descriptor ID column for another logical column, do the following:
1. Using the Oracle BI Administration tool, open your repository either offline or online.
2. Navigate to the business model and mapping layer and locate the descriptive logical
column that you wish to designate an ID column for (for example, Product Name).
3. Double-click the column to display the Logical Column dialog box. Locate the
Descriptor ID Column area and click the Set button. Pressing this button displays the
Browse dialog box, which you can then use to select the column you wish to use as the
descriptor ID column (for example, Product ID).
WITH
SAWITH0 AS (select sum(T117.REV_AMT) as c1,
T107.PROD_CAT_DESC as c2,
T107.PROD_ID as c3
from
GCBC_SALES.PRODUCTS T107,
GCBC_SALES.SALES T117
where ( T107.PROD_ID = T117.PROD_ID and (T107.PROD_ID in (12, 17,
31)) )
Existing analyses that filter on the Product Name column do not need to be changed, as the
Oracle BI Server will substitute the descriptor ID column in any filters automatically.
Until now in this chapter, we have looked at importing and then modeling data sourced from
relational data sources. In some cases, though, you may wish to report against data from
sources such as Microsoft Excel spreadsheets, text files, or XML documents either on
networked file systems or accessed over the Internet.
In the next section, we will look at how file and XML sources are accessed and how you
create physical models that can then be used along with other physical models to create the
business model and presentation layers in your Oracle BI Repository. As official support for
these sources varies by type, we will also look at the restrictions and limitations in working
with these sources so you can make a decision as to whether to access them directly from
the repository or copy their data into relational or multidimensional databases and access
them from there instead.