You are on page 1of 50

COGNOS(R) 8

FRAMEWORK MANAGER GUIDELINES FOR MODELING


METADATA

Cognos(R) 8 Business Intelligence Readme


Guidelines for Modeling Metadata

GUIDELINES FOR MODELING METADATA

TM
THE NEXT LEVEL OF PERFORMANCE
Product Information
(R)
This document applies to Cognos 8 Version 8.1.2 MR2 and may also apply to subsequent releases. To check for newer versions of this
document, visit the Cognos support Web site (http://support.cognos.com).

Copyright
Copyright (C) 2006 Cognos Incorporated.
Portions of Cognos(R) software products are protected by one or more of the following U.S. Patents: 6,609,123 B1; 6,611,838 B1; 6,662,188
B1; 6,728,697 B2; 6,741,982 B2; 6,763,520 B1; 6,768,995 B2; 6,782,378 B2; 6,847,973 B2; 6,907,428 B2; 6,853,375 B2.
Cognos and the Cognos logo are trademarks of Cognos Incorporated in the United States and/or other countries. All other names are
trademarks or registered trademarks of their respective companies.
While every attempt has been made to ensure that the information in this document is accurate and complete, some typographical errors or
technical inaccuracies may exist. Cognos does not accept responsibility for any kind of loss resulting from the use of information contained in
this document.
This document shows the publication date. The information contained in this document is subject to change without notice. Any
improvements or changes to either the product or the document will be documented in subsequent editions.
U.S. Government Restricted Rights. The software and accompanying materials are provided with Restricted Rights. Use, duplication, or
disclosure by the Government is subject to the restrictions in subparagraph (C)(1)(ii) of the Rights in Technical Data and Computer Software
clause at DFARS 252.227-7013, or subparagraphs (C) (1) and (2) of the Commercial Computer Software - Restricted Rights at
48CFR52.227-19, as applicable. The Contractor is Cognos Corporation, 15 Wayside Road, Burlington, MA 01803.
This software/documentation contains proprietary information of Cognos Incorporated. All rights are reserved. Reverse engineering of this
software is prohibited. No part of this software/documentation may be copied, photocopied, reproduced, stored in a retrieval system,
transmitted in any form or by any means, or translated into another language without the prior written consent of Cognos Incorporated.
Table of Contents

Chapter 1: Guidelines for Modeling Metadata 5


Some Objects You Will Work With in Cognos 8 5
Determinants 6
Regular Dimension 6
Measure Dimension 6
Scope Relationship 7
Dimensional Modeling of Relational Data Sources 7
Verifying Imported Metadata 7
Simplifying the Model Using Dimensional Concepts 11
Resolving Ambiguous Relationships 12
Defining Determinants 16
Defining Dimensions 17
Creating Star Schema Groups 23
Upgrading a Best Practices Model from ReportNet 1.x 24
Reviewing the Existing Model 25
Upgrading the Model 25
Chapter 2: The SQL Generated by Cognos 8 33
Understanding Dimensional Queries When Using Best Practices 33
Single Fact Query 33
Multiple-fact, Multiple-grain Query on Conformed Dimensions 34
Modeling 1-n Relationships as 1-1 Relationships 36
Multiple-fact, Multiple-grain Query on Non-Conformed Dimensions 37
Resolving Ambiguously Identified Dimensions and Facts 39
Query Subjects That Represent a Level of Hierarchy 39
Resolving Queries That Should Not Have Been Split 40
Resolving Queries That Are Split in the Wrong Place 43
Index 47

Guidelines for Modeling Metadata 3


4 Framework Manager
Chapter 1: Guidelines for Modeling Metadata

Framework Manager is a metadata modeling tool. A model is a business presentation of the


information in one or more data sources. When you add security, multilingual metadata, and
dimensional metadata to this business presentation, one model can serve the reporting, ad hoc
querying, and analysis needs of many groups of users around the globe.
A key goal of preparing metadata for business intelligence is to leverage existing metadata while
adding value so that your users can find the information that they need.
Cognos 8 enables business intelligence on normalized and denormalized relational data sources as
well as a variety of OLAP data sources.
This document addresses some fundamental concepts for modeling relational data sources in
Framework Manager and outlines our recommendations for modeling metadata for use in
business reporting and analysis. You can use Framework Manager to model any relational data
source dimensionally. Although it is not mandatory that a dimensional schema be used in
Cognos 8, many features were added to help you leverage the benefits of dimensional schemas as
well as to create a logical dimensional view of non-dimensional schemas.
The topics in this document are organized according to different scenarios: dimensional modeling
of relational data sources (p. 7) and upgrading a best practices model from ReportNet 1.x (p. 24).
Use the scenario that matches your goals.

Some Objects You Will Work With in Cognos 8


In ReportNet 1.x, dimension information combined the concept of uniqueness with the concept of
dimensional hierarchies. In Cognos 8, the concept of dimension information is divided between
determinants and hierarchies for regular dimensions. Determinants control uniqueness and
granularity. This control is required for relationally-based query subjects. Hierarchies for regular
dimensions explicitly address dimensional concepts of hierarchies, levels, keys, and attributes for
all data sources.
When reviewing dimension information, you must understand how the dimension information is
applied to the query subject and how the query subject will be used in the Cognos 8 model.
New objects have been introduced in Cognos 8:
• determinants for query subjects
• regular dimensions
• measure dimensions
• scope relationships
Determinants are not the same as levels and hierarchies but they can be closely related to a single
hierarchy. The query engine evaluates determinants from first to last. One or more determinants
may be specified.
If a model regular dimension is based on a query subject with determinants specified, we
recommend that
• one level correspond to each determinant that exists in the query subject
• the order of the levels in the hierarchy reflect the order of the determinants
This results in a consistent model, facilitating upgrading the model in future releases of Cognos
products.

Guidelines for Modeling Metadata 5


Chapter 1: Guidelines for Modeling Metadata

Determinants
Determinants are designed to provide control over granularity in a similar, but not identical, way
as dimension information in Cognos ReportNet. A determinant can define the set of database
columns (query items) that uniquely identify a set of data, or it can identify a set of columns that
identify a non-unique set within the data.
Determinants are most closely related to the concept of keys and indexes in the data source and
are imported based on key and index information in the data source. We recommend that you
always review the determinants that are imported.
There is no concept of hierarchy in determinants. The order in which they are specified governs
the order in which they are evaluated.
Use determinants in the following cases:
• Joins exist at multiple levels of granularity for a single query subject.
An example is the Time dimension in the Go Data Warehouse sample model. There are joins
to the Time dimension on the day key and on the month key. Determinants are used for the
Time dimension when you want to prevent double-counting for multiple-fact queries.
For example, some facts join to time on month and some facts join to time on day. Specify
determinants for time to clearly capture the functional dependency between month and day as
a minimum to prevent double-counting for those facts that join at the month key.
• BLOB data types exist in the query subject.
Querying blobs requires additional key or index type information. If this information is not
present in the data source, you can add it using determinants. Override the determinants
imported from the data source that conflict with relationships created for reporting.
For example, there are determinants on two query subjects for multiple columns but the
relationship between the query subjects uses only a subset of these columns. Modify the
determinant information of the query subject if it is not appropriate to use the additional
columns in the relationship.
• A join is specified that uses fewer keys than a unique determinant that is specified for a query
subject.
If your join is built on fewer columns than what is stored in Framework Manager within the
determinants, there will be a conflict. Resolve this conflict by modifying the relationship to
fully agree with the determinant or by modifying the determinant to support the relationship.
For more information, see "Defining Determinants" (p. 16).

Regular Dimension
A regular dimension contains descriptive and business key information and organizes the
information in a hierarchy, from the highest level of granularity to the lowest. It usually has
multiple levels and may have multiple key segments to define a level. It may also have multiple
hierarchies.
Only a single hierarchy can be defined on a data source regular dimension. This hierarchy will act
as a determinant for SQL generation. For model regular dimensions, you must define the
determinant on the underlying query subject.
Multiple-fact querying is enabled with conformed dimensions.
For more information, see "Creating Regular Dimensions" (p. 11) and "Defining
Dimensions" (p. 17).

Measure Dimension
A measure dimension is a collection of facts.
You can create a measure dimension for one or more query subjects that have a valid relationship
between them.
For more information, see "Creating Measure Dimensions" (p. 12).

6 Framework Manager
Chapter 1: Guidelines for Modeling Metadata

Scope Relationship
Scope relationships exist between measure dimensions and regular dimensions to define the level
at which the measures are available for reporting. Scope relationships govern the reporting
granularity of the regular dimension for a particular measure dimension.
Scope relationships are mandatory between measures and dimensions when reporting. The
absence of a scope relationship results in an error at runtime. Scope relationships are for reporting
purposes. They are not the same as joins and do not impact the Where clause.
You can use scope relationships to include or exclude the regular dimension from the star schema
group.
Shortcuts cannot be created for scope relationships. Scope relationships can exist only between
regular and measure dimensions. Scope relationships can also be created for shortcuts to
dimension objects. When shortcuts to dimensions are used, the scope is derived from the scope of
the target objects unless scope has been explicitly defined on the shortcuts.

Dimensional Modeling of Relational Data Sources


Dimensional modeling of relational data sources is a capability made available by Cognos 8
Framework Manager. ReportNet 1.x provided some dimensional capabilities to enable
multiple-fact querying and prevented double-counting, and Cognos 8 introduces features designed
explicitly for dimensional modeling. It is now possible to model dimensions with hierarchies and
levels and to have facts with multiple measures. You can then relate the dimensions to the
measures by setting scope in the model.
You must dimensionally model a relational data source when you want to do one or more of the
following:
• use Analysis Studio
• enable drill functionality in reports
• access member functions in the report authoring tools
We recommend that you follow this workflow when you dimensionally model relational data
sources:
❑ Import the metadata.
❑ Verify the imported metadata (p. 7).
❑ Customize the metadata.
❑ Simplify the model using dimensional concepts (p. 11).
❑ Resolve ambiguous relationships (p. 12).
❑ Define dimensions (p. 17) and determinants (p. 16).
❑ Organize the model by creating business views.
❑ Create star schema groups (p. 23).
❑ Apply security.
❑ Create packages and publish metadata.
For information about the topics not covered here, see "Designing a Project", "Preparing
Relational Metadata for Use in Reports", and "Making Metadata Available to Report Authors"
in the Framework Manager User Guide.
All examples in this document use the database view of the gosales_goretailers normalized model
or the import view of the go_data_warehouse model, which are included with the Cognos 8
samples.

Verifying Imported Metadata


After importing metadata, you must check the imported metadata in these areas:
• relationships and cardinality
• determinants

Guidelines for Modeling Metadata 7


Chapter 1: Guidelines for Modeling Metadata

• the Usage property for query items


• the Regular Aggregate property for query items
Relationships and cardinality are discussed here. For information on the Usage and Regular
Aggregate properties, see "Modifying the Properties of Query Items" in the Framework Manager
User Guide.
Cardinality is combined with dimensions to control how queries are generated so that you can
• prevent double-counting
• automatically resolve loop joins
• enable cross-fact querying for reporting and analysis
You can create model dimensions and data source dimensions. Model dimensions are built on a
foundation of query subjects that use determinants and relationships with cardinality. Data source
dimensions contain their own SQL and use hierarchy and level information as well as
relationships with cardinality to define query granularity.
Cardinality drives query behavior by allowing rules to be applied regarding the granularity of data
that is returned by an individual object and the consequence of joins between objects. The
cardinality specified in the relationship between query subjects or dimensions determines how and
when Cognos 8 generates stitched queries. Stitched queries are needed for multiple-fact querying
across conformed dimensions and across different levels of granularity.

Detecting Cardinality from the Data Source


When importing from a relational data source, cardinality is detected based on a set of rules that
you specify. The available options are
• use primary and foreign keys
• use matching query item names that represent uniquely indexed columns
• use matching query item names
The most common situation is to use primary and foreign keys as well as matching query items
that represent uniquely indexed columns. The information is used to set some properties of query
items as well as to generate relationships.
To view the index and key information that was imported, right-click a query subject or regular
dimension and click Edit Definition. For a query subject, you can change the information in the
Determinants tab.
Note: All regular dimensions begin as query subjects. If you converted a query subject to a regular
dimension, note that determinant information for the query subject is leveraged as a starting point
to define the levels of a single hierarchy. We recommend that you review the levels and keys
created in the hierarchy of the dimension.
Optional relationships, full outer joins, and many-to-many relationships can be imported from
your data source. Framework Manager will execute them as queries.
Reflexive relationships can be imported from your data source and appear in the model but
Framework Manager does not execute them as queries. Although you can view the metadata that
defines the reflexive relationship, you cannot edit a reflexive relationship in Framework Manager.
For more information, see "Reflexive and Recursive Relationships" (p. 15).

Cardinality in Generated Queries


Framework Manager supports both minimum-maximum cardinality and mandatory-optional
cardinality.
0:1 - 0 is the minimum cardinality, 1 is the maximum cardinality
1:n - 1 is the minimum cardinality, n is the maximum cardinality
A relationship with cardinality 1-n can be specified as 1:1 to 1:n when reading the maximum
cardinalities. The minimum cardinality of 1 is set to 0 for optional data. Therefore a 1-n
relationship can also be specified as 0:1 to 0:n, 0:1 to 1:n, or 1:1 to 0:n.
The basic rules for how cardinality is used are the following:

8 Framework Manager
Chapter 1: Guidelines for Modeling Metadata

• Cardinality is applied in the context of a query, meaning that only the cardinalities of items
explicitly included in the query are evaluated.
• 1-n cardinality implies fact on the n side and implies dimension on the 1 side.
• A query subject can behave as a dimension in one query and as a fact in another.
• Queries on more than one fact will result in a stitched query.
For more information, see "Single Fact Query" (p. 33) and "Multiple-fact, Multiple-grain Query
on Conformed Dimensions" (p. 34).

Modeling 1-n Relationships as 1-1 Relationships


If a 1-n relationship exists in the data but is modeled as a 1-1 relationship, SQL traps cannot be
avoided because the information provided by the metadata to the query engine is insufficient.
The most common problems that arise if 1-n relationships are modeled as 1-1 are the following:
• Double-counting for multiple-grain queries is not automatically prevented.
Cognos 8 cannot detect facts and then generate a stitched query to compensate for
double-counting, which can occur when dealing with hierarchical relationships and different
levels of granularity across conformed dimensions.
• Multiple-fact queries are not automatically detected.
Cognos 8 will not have sufficient information to detect a multiple-fact query. For
multiple-fact queries, an inner join is performed and the loop join is eliminated by dropping
the last evaluated join. Dropping a join is likely to lead to incorrect or unpredictable results
depending on the dimensions and facts included in the query.
You can deal with these issues in Report Studio by creating an inner or outer join between queries
or creating calculations that compensate for differences in granularity. This workaround requires
the report author to have detailed knowledge of the data. There is no workaround available in
Query Studio or Analysis Studio.

Detecting Determinants in the Data Source


Determinants are detected in your relational data source by using index and key information. This
information is useful when performing automatic aggregation to determine the appropriate level
of granularity to assign to a particular item in the query. We recommend that you review the
determinants that were created on import and modify them where appropriate to align with your
reporting requirements.
For normalized data sources, not all determinants may be relevant for or aligned with your
reporting requirements. We recommend that you remove any unnecessary determinants,
particularly if they conflict with relationships being created for that query subject.
For denormalized data sources, you may want to add determinants to represent non-unique key
segments that represent sets within the data. This is relevant if joins will be made on keys other
than the unique key of the query subject.

Analyzing the Model for Facts and Dimensions


To dimensionally model a relational data source for the purpose of cross-fact querying and
analysis, you must examine the underlying schema and address areas where the role of an object
as a fact or a dimension is not clear. This examination can result in creating a logical layer to
present the data as a star schema. Or you may decide to make changes to the physical data source
to deliver a higher performance application. Physical changes may include consolidating tables by
using extract-transform-load tools or creating materialized views for frequently-used
aggregations.
In a relational data source that was not de-normalized using star schema concepts, you may need
to analyze the cardinality of the imported query subjects before creating dimensions or converting
query subjects to dimensions. You must first understand the business applications of the
underlying data as well as understand how Cognos 8 generates queries.
Within the context of a query, a query subject with a cardinality of n on all its 1-n relationships to
other query subjects can be regarded as a fact. This implies that there are more rows of data in the
fact query subject than in the related query subject on the 1 side of the relationship. Any query
subject on the 1 side of a 1-n relationship to another query subject is treated as a dimension.

Guidelines for Modeling Metadata 9


Chapter 1: Guidelines for Modeling Metadata

The following examples show how schemas can be interpreted.


In the first two examples, we see that Sales Staff can relate directly to Sales Fact but can also relate
to Sales Fact through Sales Branch. Multiple sales staff belong to a sales branch and staff can
belong to different sales branches over time. To correctly determine the sales for a branch at a
given time, Sales Branch must be joined directly to Sales instead of being joined through Sales
Staff.

Example 1
In this example, all four query subjects are included in a query. The diagram shows that the query
subjects having only n cardinalities are treated as facts. Sales Staff and Order Details are treated as
facts. Order Header and Sales Branch are treated as dimensions.

Example 2
In this example, only three query subjects are included in a query. Order Details is not used in the
query. Order Header is now treated as a fact. Sales Staff continues to be treated as a fact.

Example 3
This example shows different query subjects. Arrows point to the query subjects whose cardinality
indicates that they are always facts. Areas where the behavior is dependent on the context of the
query are circled. All other query subjects behave as dimensions in all queries.

For more information, see "The SQL Generated by Cognos 8" (p. 33).

10 Framework Manager
Chapter 1: Guidelines for Modeling Metadata

Sparse Data
When modeling for analysis or reporting, it is important to consider the nature of the business
questions versus the nature of the data source.
A common scenario is that a relationship between a dimension and a fact table in a star schema is
optional. This means that not every dimensional member is mandatory in the fact table. OLAP
engines compensate for this by inserting an appropriate value when creating the OLAP structure
for any dimensional intersection points that do not have data.
When modeling, it is common to override optional relationships between dimensions and facts for
improved performance. However, when performing analysis or reporting on sparse data where
you require information about dimensional members that have no facts, outer joins must be
enabled to ensure that data is returned for valid dimensional intersection points.
For example, an Analysis Studio user wants to create this report:

2005 2006
Canada 1,000,000

Mexico 500,000 750,000

United States 1,000,000 1,250,000

To enable outer joins, we recommend that you do the following:


• Check with your database administrator to ensure that the data source can support full outer
joins.
• Import metadata with outer joins enabled.

Simplifying the Model Using Dimensional Concepts


These rules apply when modeling with query subjects or dimensions:
• Create a regular dimension for groups of query subjects that have hierarchical relationships
representing a single business concept (p. 11).
• Create a measure dimension for groups of query subjects that have factual data sharing many
regular dimensions or having a master-detail type of relationship (p. 12).
• Use the cardinality rules to identify areas of the model where the role of an object as fact or
dimension is not clear. For more information, see "Cardinality in Generated Queries" (p. 8).
The result of simplifying the model should be a layer of regular and measure dimensions that
clearly represent the data in terms of business concepts and ensure predictable query generation.
If your data source contains fact-to-fact relationships, we recommend that you handle these in the
data source.

Creating Regular Dimensions


Normalized or snowflaked data sources often have several tables that describe a single business
concept. For example, a normalized representation of Product may include four tables related by
1-n relationships. Each Product Line has one or more Product Types. Each Product Type has one
or more Products. Products have names and descriptions in multiple languages so they exist in a
Product Lookup table.

Guidelines for Modeling Metadata 11


Chapter 1: Guidelines for Modeling Metadata

An end user may not know the relationship between the individual query subjects. In addition,
having to expand each query subject or dimension and select a query item requires more clicks for
the end user.
When modeling dimensionally, you can create a regular dimension for Product that simplifies
using Product for the purpose of ad hoc query and reporting, and presents the levels of the
hierarchy as a visual cue about the relationship between the levels.
If you are maintaining a ReportNet 1.x model, you can create a model query subject with
determinants instead of a regular dimension. You can replicate the presentation effect of levels by
using query item folders. The resulting model query subject can be converted to a regular
dimension at any time.

Creating Measure Dimensions


Data sources often have master-detail tables that contain facts. An example is Order Header and
Order Detail. When these tables are used to insert and update data, this structure is beneficial.
When these tables are used for reporting and analysis, combine them in a single business concept
to simplify the model.

To simplify the model in this example, create a model query subject that combines the foreign keys
of both Order Header and Order Details and includes all measures at the Order Detail level. Then
create a measure dimension based on the model query subject.

You must always resolve ambiguously identified dimensions and facts. For more information, see
"The SQL Generated by Cognos 8" (p. 33).

Resolving Ambiguous Relationships


Ambiguous relationships occur when the data represented by a query subject or dimension can be
viewed in more than one context or role. The most common ambiguous relationships are:
• multiple valid relationships (p. 13)
• reflexive and recursive relationships (p. 15)

12 Framework Manager
Chapter 1: Guidelines for Modeling Metadata

You can resolve ambiguous relationships in Framework Manager, or the database administrator
can fix them in the data source. For example, the database administrator can remove extra
relationships, although this may not be practical. Resolving ambiguous relationships in the model
involves determining which query path to use.

Multiple Valid Relationships


A table with multiple valid relationships between itself and another table is known as a
role-playing dimension. Multiple valid relationships often occur between regular dimensions and
measure dimensions. This is most commonly seen in dimensions such as Time and Customer.
For example, the Sales fact has multiple relationships to the Time dimension on keys such as
Order Day, Ship Day, and Close Day.

Steps
1. Leave all the relationships in place in the Import View.
2. Create a model query subject for each of the roles.
Consider excluding unneeded query items to improve performance.
3. Rename the model query subject and query items appropriately for their use.
4. Ensure that a single appropriate relationship exists between each model query subject and the
fact query subject.

5. Decide how you want to use these roles with other facts that do not share the same concepts.
For example, Product Forecast has only one time key.

Guidelines for Modeling Metadata 13


Chapter 1: Guidelines for Modeling Metadata

You can do one of the following:


• Designate a specific query subject to be the conformed time dimension.
You can pick the most common role that you will use and name it clearly as a conformed
dimension. You can then ensure that this version is joined to all facts requiring it.

• You can treat ship day, order day and close day as interchangeable time dimensions with
Product Forecast fact.
In this case, you must create joins between each of the role-playing dimensions and
Product Forecast fact. You can use only one time dimension at a time when querying the
Product Forecast fact or your report may contain no data. For example, Month_key=Ship
Month Key (200401) and Month key=Close Month Key (200312).

14 Framework Manager
Chapter 1: Guidelines for Modeling Metadata

6. If modeling dimensionally, use each model query subject as the source for a regular
dimension, and name the dimension and hierarchies appropriately. Ensure that there is a
corresponding scope relationship specific to each role.

Model Objects vs. Shortcuts


You can create model objects based on the original query subjects or you can create shortcuts.
Use model query subjects when you want to create custom views of the same query subject.
Use shortcuts when you want exact replicas of a query subject in more than one place.
A shortcut that exists in the same folder as its target behaves as an alias, or independent instance.
However, a shortcut existing elsewhere in the model will behave as a reference to the original. This
approach is less flexible overall from a presentation perspective because renaming can only be
done at the object level.

Reflexive and Recursive Relationships


Reflexive and recursive relationships imply two or more levels of granularity. Framework
Manager imports reflexive relationships but does not use them when executing queries. Reflexive
relationships, which are self-joins, are shown in the model for the purpose of representation only.
To create a functioning reflexive relationship, you must create an alias using either a shortcut to
the query subject in the same folder, or a model query subject based on the query subject. You then
create a relationship between the query subject and the alias. Using a model query subject tends to
be a better option because you can specify which query items are included in the query subject.
For example, the Staff query subject has a recursive relationship between Staff Key and Manager
Key.

Steps
1. Create a model query subject to represent Manager.
2. Select which query items apply to Manager and rename them in a meaningful way.
3. Create a relationship with a 1:1 to 1:n between Staff and Manager.
For a simple two-level structure using a model query subject for Manager that is based on
Staff, the model looks like this:

Guidelines for Modeling Metadata 15


Chapter 1: Guidelines for Modeling Metadata

4. For a recursive hierarchy, repeat these steps for each additional level in the hierarchy.
For a deep recursive hierarchy, we recommend that the hierarchy be flattened in the data
source and that you model the flattened hierarchy in a single regular dimensions.
5. Select the query subjects, right-click, and click Merge in New Regular Dimension.

Defining Determinants
Use determinants to ensure that the aggregation in reports is correct and that queries generate
correctly.
For example, the following Time dimension has unique foreign keys:

Year Key Month Key Month Name Day Key Day Name
2006 200601 January 06 20060101 Sunday, January 1, 2006

2006 200601 January 06 20060102 Monday, January 2, 2006

You can define three determinants for this data set as follows -- two non-unique determinants
(Year and Month) and one unique determinant (Day). The concept is similar but not identical to
the concept of levels.

Name of the Uniquely


determinant Key Attributes Identified Group By
Year Year Key None No Yes

Month Month Key Month Name No Yes

Day Day Key Day Name Yes No


Month Key
Month Name
Year Key

Because Day Key is the unique key of the table, you can associate all the columns in the table to
this key. Because it is a unique key, the Uniquely Identified check box is selected. The Group By
check box is not selected because it is not needed when data is unique.

16 Framework Manager
Chapter 1: Guidelines for Modeling Metadata

The Month determinant is also a key but it is not unique, so the Uniquely Identified check box is
not selected. However, only Month Key is needed to identify a month in the data. If you want to
query month from this Time dimension, you write a query that uses the select distinct syntax.
This query would also be grouped by Month Key because the values are repeated. This is why the
Group By check box is selected. The same logic is applied to the Year determinant.
There is no concept of a hierarchy in determinants, but there is an order of evaluation. This means
that when you write a query that uses a column from the previous table, Cognos 8 looks for a
reference to that column by examining each determinant, one at a time. Cognos 8 stops when it
finds the first reference to the column.
For example, the following Time dimension has non-unique foreign keys:

Year Key Month Key Month Name Day Key Day Name
2006 01 January 20060101 Sunday, January 1, 2006

2006 01 January 20060102 Monday, January 2, 2006

Similar to the previous example, you can define three determinants for this data set as follows --
two non-unique determinants (Year and Month) and one unique determinant (Day). The concept
is similar but not identical to the concept of levels.

Name of the Uniquely


determinant Key Attributes Identified Group By
Year Year Key None No Yes

Month Year Key Month Name No Yes


Month Key

Day Day Key Day Name Yes No


Month Key
Month Name
Year Key

You write a query that uses Month Name. Month Name is an attribute of the Month determinant
and the Day determinant. Because the Month determinant is specified earlier in the list than the
Day determinant, it will be used in the query. As a result, you will likely see a select distinct
statement in the query and Month Key in the Group By clause.
How is this example different from the example shown above? In this example, Month Key is not
enough to identify a particular month in the data. If you want to query month from this Time
dimension, you write a query that uses the select distinct syntax and that is grouped on Year
Key and Month Key.

Defining Dimensions
You must use regular and measure dimensions to enable analysis on your relational data source.
In most data sources, regular dimensions, which contain descriptive information, are likely to be
shared by more than one measure dimension. Regular dimensions are often called shared
dimensions. Regular and measure dimensions organized into a cluster is often referred to as a star
schema group but can also be referred to as a functional or subject area group.
Measure dimensions are related to each other through the regular dimensions. To create reports
that fully compare and contrast functional areas, you may need to use more than one measure
dimension in a report.

Guidelines for Modeling Metadata 17


Chapter 1: Guidelines for Modeling Metadata

When querying across star schemas or functional areas, you must consider the role the hierarchy
plays in query generation:
• Multiple-fact, multiple-grain queries (p. 18)
• Multiple hierarchies (p. 22)

Multiple-fact, Multiple-grain Queries


Multiple-fact, multiple grain queries occur when dimensions are related to multiple fact tables at
different levels. A dimension typically has distinct levels of attribute data with business keys that
have a hierarchical relationship to each other. The report authoring tools automatically aggregate
to the lowest common level present in the report. The hierarchical relationship between level keys
is used to aggregate data to the lowest level included in the report. The potential for
double-counting arises when creating totals on columns that may contain repeated data. When the
level of granularity of the data is modeled correctly, double-counting can be avoided.
Note: You can report data at a level of a hierarchy below which it exists. This causes the data to
repeat across members at that level, but the totals are not affected.
This example shows two data source measure dimensions, Sales and Product forecast, that share
two regular dimensions, Time and Product.

The Time dimension is the focal point of the granularity issue in this example. In the underlying
data source, Sales is joined to Time on the Day key, and Product forecast is joined to Time on the
Month key. Because of the different join keys, a minimum of two levels must be clearly identified
with keys for the Time Dimension.

Data Source Dimensions


When using data source dimensions, we recommend that you create all levels that may be
necessary for reporting instead of only those levels that are immediately necessary.
Only a single hierarchy can be defined on a data source regular dimension. This hierarchy will act
as a determinant for SQL generation. For model regular dimensions, you must define the
determinant on the underlying query subject.
For example, the levels for Month and Day have their keys identified. Day is the lowest level of
the hierarchy, and the Unique Level box is selected because this data is unique in the underlying
data source.
For example, the level definitions for Month are as follows.

18 Framework Manager
Chapter 1: Guidelines for Modeling Metadata

For example, the level definitions for Day are as follows.

The Product dimension has three levels: Product line, Product type, and Product. It has
relationships to both fact tables on the Product key. All joins in the underlying tables occur on the
Product key so there are no granularity issues for this dimension. Any hierarchy that you create is
purely for the purpose of drilling and rollup.

Guidelines for Modeling Metadata 19


Chapter 1: Guidelines for Modeling Metadata

By default, a report is aggregated to retrieve records from each fact table at the lowest common
level of granularity. If you create a report that uses Quantity from Sales, Expected volume from
Product forecast, Month_name from the Time dimension, and Product_name from the Product
dimension, the report retrieves records from each fact table at the lowest common level of
granularity. In this example, it is at the month and product level.
If you do not specify the levels of the hierarchy properly in the Time dimension, incorrect
aggregation may occur. For example, Expected volume values that exist at the Month level in
Product forecast is rolled up based on the lower time level, days, in the Time dimension. The
values for Expected volume are multiplied by the number of days in the month.

To prevent double-counting when data exists at multiple levels of granularity, create a hierarchy
for the Time dimension and correctly specify the levels with keys.
Note the different numbers in the Expected Volume column. Double-counting was prevented.

Model Regular Dimensions and Query Subjects with Determinants


Determinants are not the same as levels and hierarchies but they can be closely related to a single
hierarchy. The query engine evaluates determinants from first to last. One or more determinants
may be specified.
If a model regular dimension is based on a query subject with determinants specified, we
recommend that
• one level correspond to each determinant that exists in the query subject
• the order of the levels in the hierarchy reflect the order of the determinants
This results in a consistent model, facilitating upgrading the model in future releases of Cognos
products.
When using model dimensions, you begin with the query subjects that are the basis for the
dimension. We recommend that you create a determinant for each level that may be necessary for
reporting instead of only those levels that are immediately necessary.
For example, here is a solution for the Time dimension that is an alternative to using dimensions
as previously described. Determinants are defined for Month and Day. Note that Day is the lowest
level of the hierarchy.
For example, the determinants for Month are as follows.

20 Framework Manager
Chapter 1: Guidelines for Modeling Metadata

For example, the determinants for Day are as follows.

The Uniquely Identified check box is selected for only the lowest level of the hierarchy because the
data in this column is unique for every row in the underlying data source.
The Group By check box is selected for all levels whose data is not unique. If aggregation on an
associated attribute is required, the key defined for the determinant should be used in a Group By
clause in the query. Also, if an attribute of a Group By level is included in a query, a Minimum
aggregate function may be used to ensure that the value is unique in the query.
The hierarchy for the model regular dimension would be the same as the one shown for the data
source dimension.
For information about the SQL and the results generated for this example, see "Multiple-fact,
Multiple-grain Query on Conformed Dimensions" (p. 34).

Guidelines for Modeling Metadata 21


Chapter 1: Guidelines for Modeling Metadata

Multiple Hierarchies
Multiple hierarchies occur when different structural views can be applied to the same data.
Depending on the nature of the hierarchies and the required reports, you may need to evaluate the
modeling technique applied to a particular case.
You can specify multiple hierarchies on regular dimensions in Framework Manager. Multiple
hierarchies for a regular dimension behave as views of the same query. You cannot use the
different hierarchies of the same dimension in a single report query.
For example, sales staff can be viewed by manager or geography. In the report authoring tools,
these hierarchies are separate but interchangeable logical structures, which are bound to the same
underlying query.
Here is sales staff as a single dimension with two hierarchies:

The hierarchies are defined in Framework Manager as follows.

If you need more than one hierarchy from a dimension, such as on opposing axes of an analysis,
you must create a regular dimension for each hierarchy. Each regular dimension must be a single
distinct hierarchy. In this way, you can issue the same, or slightly different, block of SQL multiple
times.
Here are separate dimensions for each hierarchy.

22 Framework Manager
Chapter 1: Guidelines for Modeling Metadata

Use this approach if dramatically different sets of columns are relevant for each hierarchy and it is
more intuitive for end users to model the hierarchies as separate dimensions with separate and
simpler queries.

Creating Star Schema Groups


Star schema groups can make the model more intuitive for end users by indicating which regular
dimensions and measure dimensions are related. Star schema groups can also facilitate
multiple-fact reporting by indicating how to use regular dimensions that are common to many
measure dimensions. Multiple-fact reporting is also known as cross-functional reporting.
Star schema groups also provide context for queries with ambiguous joins. By creating star
schema groups in the business view of the model, you can clarify which join path to select when
multiple join paths are available. This is particularly useful for fact-less queries.

Multiple Conformed Star Schemas or Fact-less Queries


You will likely see conformed regular dimensions between measure dimensions. Join ambiguity is
an issue when you report using items from multiple dimensions without including any items from
the measure dimension. This is called a fact-less query.
For example, Product and Time are regular dimensions related to the Product forecast and Sales
measure dimensions.

Using these relationships, how do you write a report that uses only the Product and Year items?
The business question could be which products were forecasted for sale in 2005 or which
products were actually sold in 2005. Although this query involves only the Product and Time
dimensions, these dimensions are related through multiple measure dimensions. There is no way
to guess which business question is being asked. You must set the context for the fact-less query.
In this example, we recommend that you create two namespaces, one containing Product, Time,
and Product forecast, and another containing Product, Time, and Sales.

Guidelines for Modeling Metadata 23


Chapter 1: Guidelines for Modeling Metadata

When you create these namespaces, use the Create Star Schema Grouping wizard to select the
correct dimensions for each measure, create shortcuts for all objects, and move the shortcuts to a
new namespace.
When you do this for all star schemas, you resolve join ambiguity by placing shortcuts to the
measure dimension and all regular dimensions in a single namespace. The shortcuts for conformed
dimensions in each namespace are identical and are references to the original object.
With a namespace for each star schema, it is now clear to the end users which items to use. To
create a report on Products Sold in 2005, they use Product and Year from the Sales Namespace.
The only relationship that is relevant in this context is the relationship between Product, Time,
and Sales Fact, and it is used to return the data.

Upgrading a Best Practices Model from ReportNet 1.x


If you used the modeling recommendations in the Modeling in Framework Manager for
Predictable Queries and Results paper, which is available from the Cognos support Web site
(http://support.cognos.com ), to create the ReportNet 1.x model, most of the upgrade to the new
functionality of Cognos 8 can be performed in Framework Manager. The Verify Model command
was enhanced so that you can select objects in the model and automatically convert them to
Cognos 8 dimensions. If you move forward to dimensions, the existing dimension information in
your model is used to create the first hierarchy and levels. Alternatively, you can keep query
subjects and translate ReportNet 1.x dimension information into determinants.
Part of the Cognos 8 installation automatically updates all published models to work in Cognos 8.
To begin reporting, you do not need to modify these models. When you want to reflect changes in
the data or metadata or use new features, you must explicitly upgrade the model in Framework
Manager. When you upgrade, you must decide when and where to use new features. Tools in
Framework Manager help you upgrade to new features based on the existing metadata in the
model.
When upgrading the model, you can maintain and update an existing application, or you can
leverage the existing model to create a new application.
Use this workflow when you want to support the maintenances or update and extension of an
existing application:
❑ Review the existing model (p. 25).
❑ Upgrade the model (p. 25).
❑ Verify the model (p. 27).
❑ Select and repair objects (p. 27).
❑ Convert query subject that have dimension information to query subjects with determinants
(p. 27).
❑ Review the determinants.
❑ Test the business view.

24 Framework Manager
Chapter 1: Guidelines for Modeling Metadata

❑ Republish the metadata.


❑ (optional) Create a dimensional view, or layer, in the model to enable drill-through and
analysis.
Use this workflow when you want to leverage an existing model to create a new application:
❑ Review the existing model (p. 25).
❑ Upgrade the model (p. 25).
❑ Verify the model (p. 27).
❑ Select and repair objects (p. 27).
❑ Convert query subject that have dimension information to regular dimensions (p. 29).
❑ Review the dimensions.
❑ Create measure dimensions or convert facts to measure dimensions (p. 12).
❑ Create and test star schema groups (p. 23).
❑ Publish the metadata.
For information about the topics not covered here, see "Preparing Relational Metadata for Use in
Reports" and "Making Metadata Available to Report Authors" in the Framework Manager User
Guide.
All examples in this document use the database view of the gosales_goretailers normalized model
or the import view of the go_data_warehouse model, which are included with the Cognos 8
samples.

Reviewing the Existing Model


In ReportNet 1.x, dimension information combined the concept of uniqueness with the concept of
dimensional hierarchies. In Cognos 8, the concept of dimension information is divided between
determinants and hierarchies for regular dimensions. Determinants control uniqueness and
granularity. This control is required for relationally-based query subjects. Hierarchies for regular
dimensions explicitly address dimensional concepts of hierarchies, levels, keys, and attributes for
all data sources.
When reviewing dimension information, you must understand how the dimension information is
applied to the query subject and how the query subject will be used in the Cognos 8 model.
Before upgrading the model to Cognos 8, we recommend that you review the ReportNet 1.x
model using the Modeling in Framework Manager for Predictable Queries and Results paper. You
must ensure that dimension information was specified correctly. The upgrade process provides the
option to use the dimension information to create query subjects with determinants or data source
regular dimensions. Note that for a data source regular dimension, information about the
uniqueness of keys and levels replaces determinants. Dimensions and determinants control
granularity and automatic aggregation as well as prevent double-counting in Cognos 8.
We highly recommend that you run the Verify Model command in ReportNet 1.x and repair all
errors and review all warnings before you start the upgrade.

Upgrading the Model


When you upgraded from ReportNet 1.x to Cognos 8, your published models were automatically
upgraded in the Content Manager database. These models continue to function as they did in
ReportNet. Upgrading the model in Framework Manager is required only if you want to modify
the metadata that you published.
When you open a ReportNet model in Cognos 8 Framework Manager, you are immediately
prompted to back up the model before proceeding. The original model is automatically upgraded
to include some Cognos 8 functionality. After this automatic upgrade, you must manually review
some specific changes that may change query behavior. The initial automated upgrade to
Cognos 8 produces a model that can be published to a Cognos 8 report server. This model may
require additional modifications.

Guidelines for Modeling Metadata 25


Chapter 1: Guidelines for Modeling Metadata

Most changes to modeling concepts in Cognos 8 are in the areas of data types, dimensions, and
determinants. We recommend that you review the changes listed below before publishing to the
Cognos 8 report server.

Changes to Data Types


Cognos 8 added support for new data types. This may change how data types are mapped
between Cognos and the source data on metadata import. The primary areas of change are as
follows:
• nChar
In some cases, data types that were char become nChar.
• nVarChar
In some cases, data types that were varChar become nVarChar.
• numeric
In some cases, data types that were decimal become numeric.
• timestampTZ
In some cases, data types that were varChar become timestampTZ.
• IntervalTZ
In some cases, data types that were varChar become IntervalTZ.
Mapping of these data types varies by data source vendor and can be confirmed from the data
type support section of the Cognos support Web site (http://support.cognos.com).
The Allow enhanced model portability at runtime governor is selected upon initial upgrade. This
governor prevents rigid enforcement of data types so that the Cognos 8 model can function as a
ReportNet 1.x model until you update the data types in the metadata.
It is not possible to automatically determine the new data type based on the existing data types
saved in the model. For this reason, use the Verify Model, Verify Selected Objects, Evaluate, or
Update Object commands to update the mapping of the data types.
Some query items may appear as broken after the upgrade, particularly calculations. For some
calculations, it may not be possible to automatically assign a data type due to the changes in the
data type of the underlying items. Or you may have created a calculation that uses a prompt and
did not test the calculation before saving it. For these cases, we recommend that you open and test
the calculation or query item that is affected. This will correct the data type.

Dimension Information vs. Determinants and Dimensions


In ReportNet 1.x, dimension information combined the concept of uniqueness with the concept of
dimensional hierarchies. In Cognos 8, the concept of dimension information is divided between
determinants and hierarchies for regular dimensions. Determinants control uniqueness and
granularity. This control is required for relationally-based query subjects. Hierarchies for regular
dimensions explicitly address dimensional concepts of hierarchies, levels, keys, and attributes for
all data sources.
When reviewing dimension information, you must understand how the dimension information is
applied to the query subject and how the query subject will be used in the Cognos 8 model.
The metadata previously specified by dimension information is implicitly preserved in the model
and continues to exist for query subjects until those query subjects are repaired. You cannot
change this dimension information. You can upgrade the dimension information to regular
dimensions or determinants. Until you upgrade the query subject, Cognos 8 query generation uses
the dimension information previously specified in ReportNet 1.x.
The Allow dynamic generation of dimension information governor is selected upon initial
upgrade. This governor ensures consistent behavior with ReportNet 1.x by deriving a form of
dimension information from the relationships, key information, and index information in the data
source.

26 Framework Manager
Chapter 1: Guidelines for Modeling Metadata

Verify the Model


After automatically updating the metadata, Framework Manager prompts you to verify the
model. You will likely see at least one warning for each object that contains dimension
information or one of the data types listed previously. We recommend that you check one
namespace at a time in large models. You can also check an individual object.

Understanding Warnings
The following warnings commonly appear when you check a ReportNet 1.x model:
• Needs reevaluation
This message is most likely related to data type changes.
The majority of items with this warning can be selected for repair. The repair option steps you
through your options for evaluating and upgrading specific elements of metadata.
Tip: You can also evaluate a query subject by using the Evaluate Object command from the
Tools menu.
• Join expression conflicts with the determinant information defined in the query subject
Sometimes the index and key information specified for a query subject implies a level of
granularity that does not match the relationships specified on a query subject. For more
information, see "Defining Dimensions" (p. 17) and "Defining Determinants" (p. 16).
• None of the query items in this level have a role Caption specified
When defining levels, you must ensure that a business key and caption roles are specified.
These roles are relevant for member functions in the report authoring tools and to assist in the
member-oriented tree in Analysis Studio.
All captions must have the string data type. If there is no attribute of this type available, create
a calculation that is a string data type and assign the member caption role to the new item.
This is primarily an issue for Analysis Studio.
• One or more determinants that describe the keys and attributes of the query subject should be
specified
When importing from a relational data source, determinants are specified for any indexes and
keys that exist in the data source. It is possible that no determinants exist on a query subject
upgraded from ReportNet 1.x, especially for model query subjects. We recommend that you
use determinants to explicitly specify the granularity of the data in the query subject and the
functional dependencies between query items. However, it is not mandatory to specify
determinants for query subjects representing a single level or fact data. Determinants are
required only if the item is a BLOB data type.

Selecting and Repairing Objects


You can select one or more of the items with check boxes and repair them. The repair process first
evaluates all selected items. This evaluation automatically resolves issues around new data types
and prompts you to deal with dimension information in the model. If you want to preserve
existing reports while extending your application to provide drill-through or analysis capability,
we recommend that you convert dimension information to determinants when you upgrade most
query subjects that used dimension information in ReportNet 1.x.

Converting Query Subjects with Dimension Information to Query Subjects with Determinants
When maintaining models that do not fully conform to ReportNet 1.x recommendations, you
may need to preserve query subjects. Dimension information is then mapped to determinants as
follows.

Dimension information Determinants


Hierarchies The order of determinants.

Levels Determinants
Uniquely Identified
Group By

Guidelines for Modeling Metadata 27


Chapter 1: Guidelines for Modeling Metadata

Dimension information Determinants


Unique Key is not selected Key segments from higher levels are included in the key.

Unique Key is selected Only the key segment, or segments, for the level are included
in the key.

Attributes Attributes
Unassociated attributes are assigned to the last determinant,
which generally corresponds to the lowest level.

For example, the Product query subject with dimension information looks like this in ReportNet
1.x.

When you convert it to a query subject with determinants, it looks like this.

Things to Review
After conversion, you must review the following:
• Uniquely Identified
The Uniquely Identified check box indicates that a determinant uniquely identifies a row in
the data set.
• Group By
The Group By check box implies a mandatory grouping will be done on any query using this
determinant or any item determined by it. This helps to resolve double-counting in the case of
dimensions being joined on different keys at different levels of granularity. If attribute items
are determined by a determinant that has the Group By check box selected, the Minimum
aggregate function is applied to them in the query.

28 Framework Manager
Chapter 1: Guidelines for Modeling Metadata

• Multiple Hierarchies
Determinants do not explicitly support the concept of hierarchies and provide no mechanism
to represent multiple hierarchies. If two hierarchies existed on a query subject in ReportNet
1.x, only the first hierarchy is upgraded to a determinant. You must create a second query
subject and manually specify the determinants for the other hierarchy.
For example, after upgrading the Product query subject to use determinants, you can further
refine it. In this example, Product key is now the unique identifier, and Product line code and
Product type code are used to group query items.

Converting Query Subjects with Dimension Information to Regular Dimensions


You can convert a query subject to a dimension by using the dimension information in the query
subject. You can also convert a dimension to a query subject with determinants at any time after
completing the upgrade.
Dimension information is mapped to regular dimensions as follows.

Dimension information Regular dimension


Hierarchies Hierarchies

Levels Levels
The first level of the hierarchy is automatically defined as the
All level. It contains a single root member, which represents
the top level of the hierarchy.
You cannot delete or move the All level. You can change its
name, description, and screen tip.

Keys _businessKey role

Unique Key Unique Level

Alphabetically first text _memberCaption role


attribute

All other attributes Can be manually assigned to be _memberDescription, custom


role, or no role

For example, the Product query subject in ReportNet 1.x has the following dimension
information.

Guidelines for Modeling Metadata 29


Chapter 1: Guidelines for Modeling Metadata

When you convert this query subject to a regular dimension, the dimension information is used to
create these hierarchies and levels in Cognos 8.

Things to Review
After conversion, you must review the following:
• Unique Level
A unique level indicates that the keys of the levels above are not necessary to identify the
members in this level.
• memberCaption role
To leverage member functions and enable dragging and dropping levels in the report
authoring tools, you must assign a memberCaption to each level in a dimension. Because this
role does not exist in ReportNet 1.x, it is mapped where possible. If there are no attributes for
the level, the absence of a caption is highlighted when you check the model.
All captions must have the string data type. If there is no attribute of this type available, create
a calculation that is a string data type and assign the member caption role to the new item.
This is primarily an issue for Analysis Studio.
• Attributes
In general, all other attributes should be included in the dimension and associated to the
correct level. By default, they are included with no role. You have the option to create custom
roles or assign attributes to existing roles.
• Multiple Hierarchies
Only the first hierarchy from a ReportNet 1.x query subject is upgraded to a dimension. You
must re-create all other hierarchies.
For example, after upgrading the Product query subject to a regular dimension, you can further
refine it. In this example, Product name is now defined as the memberCaption role.

30 Framework Manager
Chapter 1: Guidelines for Modeling Metadata

Guidelines for Modeling Metadata 31


Chapter 1: Guidelines for Modeling Metadata

32 Framework Manager
Chapter 2: The SQL Generated by Cognos 8

The SQL generated by Cognos 8 is often misunderstood. This document explains the SQL that
results in common situations.
Note: The SQL examples shown in this document were edited for length and are used to highlight
specific examples.

Understanding Dimensional Queries When Using Best


Practices
Dimensional queries are designed to enable multiple-fact querying. The basic goals of
multiple-fact querying are:
• Preserve data when fact data does not perfectly align across common dimensions, such as
when there are more rows in the facts than in the dimensions.
• Prevent double-counting when fact data exists at different levels of granularity by ensuring
that each fact is represented in a single query with appropriate grouping. Determinants may
need to be created for the underlying query subjects in some cases.

Single Fact Query


A query on a star schema group results in a single fact query.
In this example, Sales is the focus of any query written. The dimensions provide attributes and
descriptions to make the data in Sales more meaningful. All relationships between dimensions and
the fact are 1-n.

When you filter on the month and product, the result is as follows.

Guidelines for Modeling Metadata 33


Chapter 2: The SQL Generated by Cognos 8

Multiple-fact, Multiple-grain Query on Conformed Dimensions


A query on multiple facts and conformed dimensions respects the cardinality between each fact
table and its dimensions and writes SQL to return all the rows from each fact table.
For example, Sales and Product Forecast are both measure dimensions.

Note that this is a simplified representation and not an example of how this would appear in a
model built using Cognos best practices.

The Result
Individual queries on Sales and Product Forecast by Month and Product yield the following
results. The data in Sales is actually stored at the day level.

A query on Sales and Product Forecast respects the cardinality between each fact table and its
dimensions and writes SQL to return all the rows from each fact table. The fact tables are matched
on their common keys, month and product, and, where possible, are aggregated to the lowest
common level of granularity. In this case, days are rolled up to months. Nulls are often returned
for this type of query because a combination of dimensional elements in one fact table may not
exist in the other.

34 Framework Manager
Chapter 2: The SQL Generated by Cognos 8

Note that in February 2004, Course Pro Umbrellas were in the forecast but there were no actual
sales. The data in Sales and Product Forecast exist at different levels of granularity. The data in
Sales is at the day level, and Product Forecast is at the month level.

The SQL
The SQL generated by Cognos 8, known as a stitched query, is often misunderstood. A stitched
query uses multiple subqueries, one for each star, brought together by a full outer join on the
common keys. The goal is to preserve all dimensional members occurring on either side of the
query.
The following example was edited for length and is used as an example to capture the main
features of stitched queries.
select
coalesce(D2.MONTH_NAME,D3.MONTH_NAME) as MONTH_NAME,
coalesce(D2.PRODUCT_NAME,D3.PRODUCT_NAME) as PRODUCT_NAME,
D2.EXPECTED_VOLUME as EXPECTED_VOLUME,
D3.QUANTITY as QUANTITY
from (select TIME.MONTH_NAME as MONTH_NAME,
PRODUCT_LOOKUP.PRODUCT_NAME as PRODUCT_NAME,
XSUM(PRODUCT_FORECAST_FACT.EXPECTED_VOLUME for
TIME.CURRENT_YEAR,TIME.QUARTER_KEY,TIME.MONTH_KEY,
PRODUCT.PRODUCT_LINE_CODE, PRODUCT.PRODUCT_TYPE_CODE,
PRODUCT.PRODUCT_KEY) as EXPECTED_VOLUME
from
(select TIME.CURRENT_YEAR as CURRENT_YEAR,
TIME.QUARTER_KEY as QUARTER_KEY,
TIME.MONTH_KEY as MONTH_KEY,
XMIN(TIME.MONTH_NAME for TIME.CURRENT_YEAR,
TIME.QUARTER_KEY,TIME.MONTH_KEY) as MONTH_NAME
from TIME_DIMENSION TIME
group by TIME.MONTH_KEY) TIME
join PRODUCT_FORECAST_FACT PRODUCT_FORECAST_FACT
on (TIME.MONTH_KEY = PRODUCT_FORECAST_FACT.MONTH_KEY)
join PRODUCT PRODUCT on (PRODUCT.PRODUCT_KEY =
PRODUCT_FORECAST_FACT.PRODUCT_KEY)
where
(PRODUCT.PRODUCT_NAME in ('Aloe Relief','Course Pro Umbrella')) and
(TIME.MONTH_NAME in ('April 2004','February 2004','February 2006'))
group by
TIME.MONTH_NAME,
PRODUCT_LOOKUP.PRODUCT_NAME
) D2
full outer join
(select TIME.MONTH_NAME as MONTH_NAME,
PRODUCT_LOOKUP.PRODUCT_NAME as PRODUCT_NAME,
XSUM(SALES_FACT.QUANTITY for TIME.CURRENT_YEAR,
TIME.QUARTER_KEY, TIME.MONTH_KEY,
PRODUCT.PRODUCT_LINE_CODE, PRODUCT.PRODUCT_TYPE_CODE,
PRODUCT.PRODUCT_KEY ) as QUANTITY
from
select TIME.DAY_KEY,TIME.MONTH_KEY,TIME.QUARTER_KEY,
TIME.CURRENT_YEAR,TIME.MONTH_EN as MONTH_NAME
from TIME_DIMENSION TIME) TIME
join SALES_FACT SALES_FACT
on (TIME.DAY_KEY = SALES_FACT.ORDER_DAY_KEY)
join PRODUCT PRODUCT on (PRODUCT.PRODUCT_KEY = SALES_FACT.PRODUCT_KEY)
where
PRODUCT.PRODUCT_NAME in ('Aloe Relief','Course Pro Umbrella'))
and (TIME.MONTH_NAME in ('April 2004','February 2004','February
2006'))
group by
TIME.MONTH_NAME,
PRODUCT.PRODUCT_NAME
) D3
on ((D2.MONTH_NAME = D3.MONTH_NAME) and
(D2.PRODUCT_NAME = D3.PRODUCT_NAME))

Guidelines for Modeling Metadata 35


Chapter 2: The SQL Generated by Cognos 8

What Is the Coalesce Statement?


A coalesce statement is simply an efficient means of dealing with query items from conformed
dimensions. It is used to accept the first non-null value returned from either query subject. This
statement allows a full list of keys with no repetitions when doing a full outer join.

Why Is There a Full Outer Join?


A full outer join is necessary to ensure that all the data from each fact table is retrieved. An inner
join gives results only if an item in inventory was sold. A right outer join gives all the sales where
the items were in inventory. A left outer join gives all the items in inventory that had sales. A full
outer join is the only way to learn what was in inventory and what was sold.

Modeling 1-n Relationships as 1-1 Relationships


If the cardinality were modified to use only 1-1 relationships between query subjects or
dimensions, the result of a query on Product Forecast and Sales with Time or Time and Product
generates a single Select statement that drops one join to prevent a circular reference.
The example below shows that the results of this query are incorrect when compared with the
results of individual queries against Sales or Product Forecast.
The results of individual queries are as follows.

When you combine these queries into a single query, the results are as follows.

The SQL
If you look at the SQL, you can see that, because Cognos 8 detected that a circular join path exists
in the model, it did not include one of the relationships that was not necessary to complete the join
path. In this example, the relationship between Time and Product Forecast was dropped.
A circular join path rarely results in a query that produces useful results.
select
TIME_.MONTH_NAME as MONTH_NAME,
PRODUCT_LOOKUP.PRODUCT_NAME as PRODUCT_NAME,
XSUM(SALES_FACT.QUANTITY for
TIME_.CURRENT_YEAR, TIME_.QUARTER_KEY, TIME_.MONTH_KEY,
PRODUCT.PRODUCT_LINE_CODE, PRODUCT.PRODUCT_TYPE_CODE,
PRODUCT.PRODUCT_KEY ) as QUANTITY,
XSUM(PRODUCT_FORECAST_FACT.EXPECTED_VOLUME for TIME_.CURRENT_YEAR,
TIME_.QUARTER_KEY, TIME_.MONTH_KEY, PRODUCT.PRODUCT_LINE_CODE,
PRODUCT.PRODUCT_TYPE_CODE, PRODUCT.PRODUCT_KEY ) as EXPECTED_VOLUME

36 Framework Manager
Chapter 2: The SQL Generated by Cognos 8

from
(select TIME.DAY_KEY,TIME.MONTH_KEY, TIME.QUARTER_KEY,
TIME.CURRENT_YEAR,TIME.MONTH_EN as MONTH_NAME
from TIME_DIMENSION TIME) TIME
join
SALES_FACT on (TIME_.DAY_KEY = SALES_FACT.ORDER_DAY_KEY)
join
PRODUCT_FORECAST_FACT on (TIME_.MONTH_KEY =
PRODUCT_FORECAST_FACT.MONTH_KEY)
join
PRODUCT (PRODUCT.PRODUCT_KEY = PRODUCT_FORECAST_FACT.PRODUCT_KEY)
where
(PRODUCT.PRODUCT_NAME in ('Aloe Relief','Course Pro Umbrella'))
and
(TIME_.MONTH_NAME in ('April 2004','February 2004','February 2006'))
group by
TIME_.MONTH_NAME, PRODUCT.PRODUCT_NAME

Multiple-fact, Multiple-grain Query on Non-Conformed Dimensions


If a non-conformed dimension is added to the query, the nature of the result returned by the
stitched query is changed. It is no longer possible to aggregate records to a lowest common level of
granularity because one side of the query has dimensionality that is not common to the other side
of the query. The result returned is really two correlated lists.

The Result
The results of individual queries on the respective star schemas look like this.

Guidelines for Modeling Metadata 37


Chapter 2: The SQL Generated by Cognos 8

Querying the same items from both star schemas yields the following result.

In this result, the lower level of granularity for records from Sales results in more records being
returned for each month and product combination. There is now a 1-n relationship between the
rows returned from Product Forecast and those returned from Sales.
When you compare this to the result returned in the example of the multiple-fact, multiple grain
query on conformed dimensions, you can see that more records are returned and that Expected
Volume results are repeated across multiple Order Methods. Adding Order Method to the query
effectively changes the relationship between Quantity data and Expected Volume data to a 1-n
relationship. It is no longer possible to relate a single value from Expected Volume to one value
from Quantity.
Grouping on the Month key demonstrates that the result in this example is based on the same
data set as the result in the multiple-fact, multiple-grain query but with a greater degree of
granularity.

The SQL
The stitched SQL generated for this example is very similar to the SQL generated in the
multiple-fact, multiple-grain query (p. 34). The main difference is the addition of Order Method.
Order Method is not a conformed dimension and affects only the query against the Sales Fact
table.
select
D2.QUANTITY as QUANTITY,
D3.EXPECTED_VOLUME as EXPECTED_VOLUME,
coalesce(D2.PRODUCT_NAME,D3.PRODUCT_NAME) as PRODUCT_NAME,
coalesce(D2.MONTH_NAME,D3.MONTH_NAME) as MONTH_NAME,
D2.ORDER_METHOD as ORDER_METHOD
from
(select
PRODUCT.PRODUCT_NAME as PRODUCT_NAME,
TIME.MONTH_NAME as MONTH_NAME,
ORDER_METHOD.ORDER_METHOD as ORDER_METHOD,
XSUM(SALES_FACT.QUANTITY for TIME.CURRENT_YEAR,TIME.QUARTER_KEY,
TIME.MONTH_KEY,PRODUCT.PRODUCT_LINE_CODE,PRODUCT.PRODUCT_TYPE_CODE,
PRODUCT.PRODUCT_KEY,ORDER_METHOD_DIMENSION.ORDER_METHOD_KEY) as
QUANTITY
from
PRODUCT_DIMENSION PRODUCT
join
SALES_FACT SALES_FACT

38 Framework Manager
Chapter 2: The SQL Generated by Cognos 8

on (PRODUCT.PRODUCT_KEY = SALES_FACT.PRODUCT_KEY)
join
ORDER_METHOD_DIMENSION ORDER_METHOD
on (ORDER_METHOD.ORDER_METHOD_KEY = SALES_FACT.ORDER_METHOD_KEY)
join TIME_DIMENSION TIME
on ( TIME.DAY_KEY = SALES_FACT.ORDER_DAY_KEY)
where
(PRODUCT.PRODUCT_NAME in ('Aloe Relief','Course Pro Umbrella'))
and
( TIME.MONTH_NAME in ('April 2004','February 2004','February 2006'))
group by
PRODUCT.PRODUCT_NAME,
TIME.MONTH_NAME,
ORDER_METHOD.ORDER_METHOD
) D2
full outer join
(select
PRODUCT.PRODUCT_NAME as PRODUCT_NAME,
TIME.MONTH_NAME as MONTH_NAME,
XSUM(PRODUCT_FORECAST_FACT.EXPECTED_VOLUME for TIME.CURRENT_YEAR,
TIME.QUARTER_KEY,TIME.MONTH_KEY,PRODUCT.PRODUCT_LINE_CODE,
PRODUCT.PRODUCT_TYPE_CODE,PRODUCT.PRODUCT_KEY) as EXPECTED_VOLUME
from
PRODUCT_DIMENSION PRODUCT
join
PRODUCT_FORECAST_FACT PRODUCT_FORECAST_FACT
on (PRODUCT.PRODUCT_KEY = PRODUCT_FORECAST_FACT.PRODUCT_KEY)
join
(select
TIME.CURRENT_YEAR as CURRENT_YEAR,
TIME.QUARTER_KEY as QUARTER_KEY,
TIME.MONTH_KEY as MONTH_KEY,
XMIN(TIME.MONTH_NAME for TIME.CURRENT_YEAR, TIME.QUARTER_KEY,
TIME.MONTH_KEY) as MONTH_NAME
from
TIME_DIMENSION TIME
group by
TIME.CURRENT_YEAR,
TIME.QUARTER_KEY,
TIME.MONTH_KEY
) TIME
on (TIME.MONTH_KEY = PRODUCT_FORECAST_FACT.MONTH_KEY)
where
(PRODUCT.PRODUCT_NAME in ('Aloe Relief','Course Pro Umbrella'))
and
(TIME.MONTH_NAME in ('April 2004','February 2004','February 2006'))
group by
PRODUCT.PRODUCT_NAME,
TIME.MONTH_NAME
) D3
on ((D2.PRODUCT_NAME = D3.PRODUCT_NAME) and
(D2.MONTH_NAME = D3.MONTH_NAME))

Resolving Ambiguously Identified Dimensions and Facts


A query subject is considered to be ambiguously defined if it participates in both n and 1
relationships to other query subjects. An ambiguously defined query subject is not always
harmful from a query generation perspective. We suggest that you evaluate query subjects using
the following cases. The goal of this evaluation is to prevent unnecessary query splits and to
ensure that any splits that do occur are intentional and correct.

Guidelines for Modeling Metadata 39


Chapter 2: The SQL Generated by Cognos 8

Query Subjects That Represent a Level of Hierarchy


One frequent case of an ambiguously defined query subject that is not harmful is where the query
subject represents an intermediate level of a descriptive hierarchy. One example is the Product
Hierarchy found in the Go Sales sample model.

In this example, both Product type and Product could be identified as being ambiguously defined.
However, this ambiguity is not detrimental to either the results generated or the performance of
any query using one or more of these query subjects. You do not need to fix this query pattern
because, using the rules for fact detection, only one fact is identified in any query that combines an
item from the Product forecast or Sales query subjects. It remains a best practice to collapse
hierarchies into a single regular dimension when modeling for analysis purposes.
Some queries that can be written using this example include the following:

Items from these query subjects are used in a Query subject that behaves as a fact in the
query: query:
Product line and Product type Product type

Product line, Product type, and Product Product

Product line, Product type, Product, and Sales Sales

Product line and Sales Sales

Product type and Product forecast Product forecast

Resolving Queries That Should Not Have Been Split


If queries are split and should not be split, you must resolve these queries.
Query subjects on the n side of all relationships are identified as facts. We can see that in the
following example, Order Header and Country Multilingual are behaving as facts. In reality, the
Country Multilingual query subject contains only descriptive information and seems to be a
lookup table. From a dimensional or business modeling perspective, Country Multilingual is an
extension of Country.
Why is it a problem to leave the model like this?

40 Framework Manager
Chapter 2: The SQL Generated by Cognos 8

Test this model by authoring a report on the number of orders per city, per country. Using this
model returns an incorrect result. The numbers are correct for the cities but some cities are shown
as being in the wrong country. This is an example of an incorrectly related result.

Usually the first place to look when you see something like this is in the SQL.

The SQL
In this example, we see a stitched query, which makes sense if we have multiple facts in the model.
A stitched query is essentially a query that attempts to stitch multiple facts together. It uses the
relationships that relate the facts to each other as well as the determinants for the conformed, or
common, dimensions defined in the model. A stitched query can be identified by two queries with
a full outer join. The wrapper query must include a coalesce statement on the conformed
dimensions.
Note the following problems in the SQL:
• The query has no coalesce statement.
• RSUM indicates an attempt to create a valid key.
select
D3.COUNTRY as COUNTRY,
D2.CITY as CITY,
D2.number_of_orders as number_of_orders
from
(select
SALES_BRANCH.CITY as CITY,
XCOUNT(ORDER_HEADER.ORDER_NUMBER for SALES_BRANCH.CITY) as
number_of_orders,
RSUM(1 at SALES_BRANCH.CITY order by SALES_BRANCH.CITY asc local)
as sc
from
gosales.gosales.dbo.SALES_BRANCH SALES_BRANCH
join
gosales.gosales.dbo.ORDER_HEADER ORDER_HEADER
on (SALES_BRANCH.SALES_BRANCH_CODE = ORDER_HEADER.SALES_BRANCH_CODE)
group by
SALES_BRANCH.CITY
order by
CITY asc
) D2
full outer join
(select
COUNTRY_MULTILINGUAL.COUNTRY as COUNTRY,

Guidelines for Modeling Metadata 41


Chapter 2: The SQL Generated by Cognos 8

RSUM(1 at COUNTRY_MULTILINGUAL.COUNTRY order by


COUNTRY_MULTILINGUAL.COUNTRY asc local) as sc
from
gosales.gosales.dbo.COUNTRY_MULTILINGUAL COUNTRY_MULTILINGUAL
group by
COUNTRY_MULTILINGUAL.COUNTRY
order by
COUNTRY asc
) D3
on (D2.sc = D3.sc)
By looking at the stitched columns in each query, we see that they are being calculated on
unrelated criteria. This explains why there is no apparent relationship between the countries and
cities in the report.
So why do we see a stitched query? To answer that question, we must look at the model.
In this example, the query items used in the report came from different query subjects. Country
came from Country Multilingual, City came from Sales Branch, and the Number of Orders came
from a count on Order Number in the Order Header query subject.

The problem is that the query splits because the query engine sees this as a multiple-fact query.
However, the split does not have a valid key on which to stitch because there is no item that both
facts have in common.
There is more than one way to solve this problem but both require understanding the data.

Solution 1
You can add a filter to Country Multilingual that changes the cardinality of the relationship to
1-1.
Select *
from [GOSL].COUNTRY_MULTILINGUAL
Where
COUNTRY_MULTILINGUAL."LANGUAGE"=’EN’
Or you can add a filter on the relationship and change the cardinality to 1-1.
COUNTRY.COUNTRY_CODE = COUNTRY_MULTILINGUAL.COUNTRY_CODE
and COUNTRY_MULTILINGUAL.LANGUAGE = ’EN’
Either choice results in a model that has a single fact in this query.

Solution 2
Simplify the model by consolidating the related query subjects. This gives the greatest benefit by
simplifying the model and reducing the opportunities for error in query generation.

42 Framework Manager
Chapter 2: The SQL Generated by Cognos 8

With either solution, the result of the query is now correct.

The SQL is no longer a stitched query.


select
Country.c7 as COUNTRY,
SALES_BRANCH.CITY as CITY,
XCOUNT(ORDER_HEADER.ORDER_NUMBER for Country.c7,SALES_BRANCH.CITY)
as number_of_orders
from
(select
COUNTRY.COUNTRY_CODE as c1,
COUNTRY_MULTILINGUAL.COUNTRY as c7
from
gosales.gosales.dbo.COUNTRY COUNTRY
join
gosales.gosales.dbo.COUNTRY_MULTILINGUAL COUNTRY_MULTILINGUAL
on (COUNTRY.COUNTRY_CODE = COUNTRY_MULTILINGUAL.COUNTRY_CODE)
where COUNTRY_MULTILINGUAL.LANGUAGE='EN'
) Country
join
gosales.gosales.dbo.SALES_BRANCH SALES_BRANCH
on (SALES_BRANCH.COUNTRY_CODE = Country.c1)
join
gosales.gosales.dbo.ORDER_HEADER ORDER_HEADER
on (SALES_BRANCH.SALES_BRANCH_CODE = ORDER_HEADER.SALES_BRANCH_CODE)
group by
Country.c7,
SALES_BRANCH.CITY

Resolving Queries That Are Split in the Wrong Place


Sometimes using 1-n cardinality does not resolve circular join paths. Incorrect results are still
returned because of an improperly-formed stitched query.
For example, the model contains these objects.

Guidelines for Modeling Metadata 43


Chapter 2: The SQL Generated by Cognos 8

If you report on Sales Target and Actual Sales grouped by Product and Sales Staff, the result set is
incorrect. Actual Sales are a bit too large.

To check the result, query each fact separately.

This confirms that the first report is giving a much larger result for Actual Sales than it should.

The SQL
Note the following problems when you look at the SQL:
• Only one of the dimension columns has a coalesce statement. This indicates that the query
has been improperly split.
• Grouping is correct for the Sales Target side of the query. This explains why Sales Target is
accurate.
• The quantity side of the stitched query is grouped only by Product, which explains why the
Actual Sales are too large.
select
coalesce(D2.PRODUCT_NAME,D3.PRODUCT_NAME) as PRODUCT_NAME,
D2.LAST_NAME as LAST_NAME,
D2.SALES_TARGET as SALES_TARGET,
D3.Actual_sales as Actual_sales
from
(select
Product.PRODUCT_NAME as PRODUCT_NAME,
SALES_STAFF.LAST_NAME as LAST_NAME,
XSUM(SALES_TARGET.SALES_TARGET for
Product.PRODUCT_NAME,SALES_STAFF.LAST_NAME) as SALES_TARGET
from
(select PRODUCT_MULTILINGUAL.PRODUCT_NAME,PRODUCT.PRODUCT_NUMBER
from
gosales.gosales.dbo.PRODUCT PRODUCT,

44 Framework Manager
Chapter 2: The SQL Generated by Cognos 8

gosales.gosales.dbo.PRODUCT_MULTILINGUAL PRODUCT_MULTILINGUAL where


PRODUCT.PRODUCT_NUMBER = PRODUCT_MULTILINGUAL.PRODUCT_NUMBER) Product
join
gosales.gosales.dbo.SALES_TARGET SALES_TARGET
on (Product.PRODUCT_NUMBER = SALES_TARGET.PRODUCT_NUMBER)
join
gosales.gosales.dbo.SALES_STAFF SALES_STAFF
on (SALES_STAFF.SALES_STAFF_CODE = SALES_TARGET.SALES_STAFF_CODE)
group by
Product.PRODUCT_NAME,
SALES_STAFF.LAST_NAME
) D2
full outer join
(select
Product.PRODUCT_NAME as PRODUCT_NAME,
XSUM(XSUM((ORDER_DETAILS.QUANTITY * ORDER_DETAILS.UNIT_SALE_PRICE)
for Product.PRODUCT_NAME) at Product.PRODUCT_NAME
for Product.PRODUCT_NAME)as Actual_sales
from
(select PRODUCT_MULTILINGUAL.PRODUCT_NAME,PRODUCT.PRODUCT_NUMBER
from
gosales.gosales.dbo.PRODUCT PRODUCT,
gosales.gosales.dbo.PRODUCT_MULTILINGUAL
PRODUCT_MULTILINGUAL where PRODUCT.PRODUCT_NUMBER =
PRODUCT_MULTILINGUAL.PRODUCT_NUMBER) Product
join
gosales.gosales.dbo.ORDER_DETAILS ORDER_DETAILS
on (Product.PRODUCT_NUMBER = ORDER_DETAILS.PRODUCT_NUMBER)
group by
Product.PRODUCT_NAME
D3
on (D2.PRODUCT_NAME = D3.PRODUCT_NAME)
These problems exist because nothing was selected from Order Header. It was not included in the
query so there was no way to link Sales Staff to Order Details. Linking Sales Staff to Order Details
was not necessary to connect all the tables because there was already a relationship between Sales
Staff and Sales Target.
Although you can resolve this by including an item from Order Header in the report, your users
may not know to do that. We recommend that you fix it in the model. This is the recommended
solution from both a dimensional and business modeling standpoint. In addition, a simpler model
makes it harder to write a report that generates bad SQL.
Consolidate query subjects where logical groupings are possible. In this example, combine the
Order Details and Order Header query subjects. The new group of query subjects can now be
used for dimensional modeling.

Guidelines for Modeling Metadata 45


Chapter 2: The SQL Generated by Cognos 8

When you use this new group of query subjects, the report looks like this.

When you look at the SQL, you see this:


select
coalesce(D2.PRODUCT_NAME,D3.PRODUCT_NAME) as PRODUCT_NAME,
coalesce(D2.LAST_NAME,D3.LAST_NAME) as LAST_NAME,
D2.SALES_TARGET as SALES_TARGET,
D3.Actual_sales as Actual_sales
from
(select
Product.PRODUCT_NAME as PRODUCT_NAME,
SALES_STAFF.LAST_NAME as LAST_NAME,
XSUM(SALES_TARGET.SALES_TARGET for
Product.PRODUCT_NAME,SALES_STAFF.LAST_NAME) as SALES_TARGET
from
(select PRODUCT_MULTILINGUAL.PRODUCT_NAME,PRODUCT.PRODUCT_NUMBER
from
gosales.gosales.dbo.PRODUCT PRODUCT,
gosales.gosales.dbo.PRODUCT_MULTILINGUAL
PRODUCT_MULTILINGUAL where PRODUCT.PRODUCT_NUMBER =
PRODUCT_MULTILINGUAL.PRODUCT_NUMBER) Product
join
gosales.gosales.dbo.SALES_TARGET SALES_TARGET
on (SALES_TARGET.PRODUCT_NUMBER = Product.PRODUCT_NUMBER)
join
gosales.gosales.dbo.SALES_STAFF SALES_STAFF
on (SALES_STAFF.SALES_STAFF_CODE = SALES_TARGET.SALES_STAFF_CODE)
group by
Product.PRODUCT_NAME,
SALES_STAFF.LAST_NAME
) D2
full outer join
(select
Product.PRODUCT_NAME as PRODUCT_NAME,
SALES_STAFF.LAST_NAME as LAST_NAME,
XSUM((ORDER_DETAILS_ORDER_HEADER.c5 * ORDER_DETAILS_ORDER_HEADER.c8)
for Product.PRODUCT_NAME,SALES_STAFF.LAST_NAME ) as Actual_sales
from
(select PRODUCT_MULTILINGUAL.PRODUCT_NAME,PRODUCT.PRODUCT_NUMBER
from
gosales.gosales.dbo.PRODUCT PRODUCT,
gosales.gosales.dbo.PRODUCT_MULTILINGUAL
PRODUCT_MULTILINGUAL where PRODUCT.PRODUCT_NUMBER =
PRODUCT_MULTILINGUAL.PRODUCT_NUMBER) Product
join
(select
ORDER_DETAILS.PRODUCT_NUMBER as c4,
ORDER_DETAILS.QUANTITY as c5,
ORDER_DETAILS.UNIT_SALE_PRICE as c8,
ORDER_HEADER.SALES_STAFF_CODE as c14
from
gosales.gosales.dbo.ORDER_DETAILS ORDER_DETAILS
join
gosales.gosales.dbo.ORDER_HEADER ORDER_HEADER
on (ORDER_HEADER.ORDER_NUMBER = ORDER_DETAILS.ORDER_NUMBER)

46 Framework Manager
Chapter 2: The SQL Generated by Cognos 8

) ORDER_DETAILS_ORDER_HEADER
on (ORDER_DETAILS_ORDER_HEADER.c4 = Product.PRODUCT_NUMBER)
join
gosales.gosales.dbo.SALES_STAFF SALES_STAFF
on (SALES_STAFF.SALES_STAFF_CODE = ORDER_DETAILS_ORDER_HEADER.c14)
group by
Product.PRODUCT_NAME,
SALES_STAFF.LAST_NAME
) D3
on ((D2.PRODUCT_NAME = D3.PRODUCT_NAME) and (D2.LAST_NAME = D3.LAST_NAME)))

Guidelines for Modeling Metadata 47


Chapter 2: The SQL Generated by Cognos 8

48 Framework Manager
Index

A dimensions (cont'd)
star schema groups, 23
ambiguous objects, 39
upgrading to, 26
attributes, 27, 29
document
version, 2
C double-counting, 6, 9, 36, 39
cardinality
1-1, 36 F
1-n, 36
fact-less query, 23
checking, 7
facts, 6, 12
data source, 8
ambiguous, 39
dimensions and facts, 9
identifying, 9
queries, 8
full outer joins, 8
rules, 8
types, 8
circular joins, 43 G
conformed dimensions granularity, 15
multiple facts, 34, 37
conformed star schema groups, 23
copyright, 2
H
creating hierarchies, 6, 16, 18, 27, 29
measure dimensions, 12 multiple, 22
regular dimensions, 11
star schema groups, 23 I
cross-fact queries, 9 identifiers
unique, 6
D imported metadata
data source dimensions, 18 checking, 7
data types, 26
determinants, 6 J
cardinality, 8 joins
converting from dimension information, 27 circular, 43
defining, 16 full outer, 8
upgrading to, 26
dimension information, 27, 29
dimensional queries, 33 K
multiple facts and grains, 34, 37 keys, 8, 27, 29
single fact, 33
dimensionally modeling relational metadata, 7 L
dimensions
ambiguous, 39 levels, 6, 27, 29
converting from query subjects, 29
data source, 18 M
hierarchies, 22 mandatory cardinality, 8
identifying, 9 many-to-many relationships, 8
measure, 6, 12 master-detail tables, 12
model, 18 maximum cardinality, 8
query subjects, 18 measure dimensions, 6
regular, 6, 11, 18 creating, 12
reviewing, 30 role-playing, 13
role-playing, 13 minimum cardinality, 8
scope relationships, 7 model dimensions, 18

Guidelines for Modeling Metadata 47


Index

models star schema groups


repairing, 27 creating, 23
reviewing, 25 multiple conformed, 23
upgrading, 25 stitched queries, 7
multiple hierarchies, 22
multiple valid relationships, 13 U
multiple-fact queries, 18, 34, 37
multiple-grain queries, 18, 34, 37 unique identifiers, 6
unique keys, 27, 29
upgrading
O data types, 26
one-to-many relationships, 9, 36 upgrading models, 25
one-to-one relationships, 9, 36 converting, 27, 29
optional cardinality, 8 from ReportNet 1.x, 24
optional relationships, 8 repairing, 27
outer joins reviewing, 25
full, 8 warnings, 27

Q V
queries valid relationships
fact-less, 23 multiple, 13
multiple-fact, 18, 34, 37 verifying models, 27
multiple-grain, 18 version
single fact, 33 document, 2
split, 40, 43
stitched, 7 W
query subjects
converting to dimensions, 29 workflows, 7, 24
determinants, 27
dimensions, 18
star schema groups, 23

R
recursive relationships, 15
reflexive relationships, 15
regular dimensions, 6, 18
creating, 11
role-playing, 13
relationships
1-n, 9, 36
checking, 7
levels of granularity, 15
many-to-many, 8
multiple valid, 13
scope, 7
repairing models, 27
resolving
ambiguous objects, 39
split queries, 40, 43
reviewing models, 25
role-playing dimensions, 13
rules of cardinality, 8

S
scope relationships, 7
simplifying models, 11
single fact queries, 33
split queries, 40, 43
SQL, 33

48 Framework Manager

You might also like