You are on page 1of 36

Cognos Express Cookbook DMR - Dimensionally Modeled Relational

Model

DMR - Dimensionally
Modeled Relational Model
The Problem
You want to create a dimensionally modeled relational model from a
relational data source so you can publish the data for your business users
to query.

The Solution
Framework Manager

The Steps
1. Create a Project
2.
3.
4.
5.

Learn the Components


Create Relationships
Build Business View
Build Presentation View

6. Publish Package
open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

Step 1: Create a Project


Start Framework Manager from your Windows Start Menu:
Start > All Programs > IBM Cognos Express > Framework Manager
1. Click Create a new project.

Note: We can jumpstart a new project with the Model Design Accelerator
(MDA) wizard to create a single-fact star-schema model, but it may contain
errors that's difficult to catch.

2. A New Project dialog opens. Give your project a name. Click OK.
3. After logging in and selecting a language, the Metadata Wizard will start.
open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

In Select Metadata Source, choose Data Sources.

4. In Select Data Source, there will be a list of data sources that was configured in
Cognos. Choose foodmart-reduced. Click Next.
5. In Select Objects, expand dbo, and check Tables. In this example, well
choose all tables.

Usually, you would only pick the tables necessary for the query or star
open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

schema, but the foodmart-reduced data source is small enough.

6. In Generate Relationships, uncheck Use primary and foreign keys so


you can manually create the model. Click Import.

Note: The wizard can create relationships with the joins and cardinality from
open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

the data source, but it will still need manual adjustments, and it's possible for
one to miss a detail because the lack of knowledge about the model. So it's
recommended to take the manual route.

7. When the wizard completes the import process, there should be 8 query subjects
(one per table). Click Finish. Congratulations. You created a project. Now its time
to get familiar with the different kinds of objects and components so we can
open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

improve the model.

Step 2: Learn the Components


So you just created a project which is a set of components that defines
metadata from one or multiple data sources. Those components include:
Namespace

location that contains all the metadata.

Data
Sources

references to data sources defined in Cognos Manager

Parameter
Maps

key-value pairs that link query items to relational data sources.

Packages

open in browser PRO version

collections of objects from the project's namespace that is published for


business users to query.

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

A Namespace is an object that uniquely identifies stored and organized


objects that are found in your model.

Note: Uniquely identifies means that a namespace has its own scope so two different
namespaces can have an object with the same name and there won't be any conflict
because they do not affect one another. You can link one object to an object in
another namespace though. It'll hopefully make more sense by the end of this recipe.
A Namespace can contain:
Query
Subjects

they're like tables in relational data sources and usually contains


Query Items (which are like columns in a table).

Relationships

join and cardinality between two Query Items; similar to


relationaships in SQL databases.

Folders

nothing special. Just for organization.

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

And More
Namespaces

Step 3: Create Relationships


In Step 1, query subjects were imported. Now we need to create
relationships and join the query items with the correct cardinality. Its
important to join query items correctly so business users will have the
correct results. Since we imported all tables, creating relationships in
Framework Manager would be as simple as copying the database
schema.
open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

1. Expand promotion and sales_fact 1997 query subjects.


2. Both promotion and sales_fact 1997 query subjects have a promotion_id query
item. Single click promotion_id in either query subject and single click the other
promotion_id query item while holding down the Ctrl key.
3. Right click either promotion_id query item thats selected. Go to Create
open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

> Relationship.

4. Under sales_fact 1997, change the cardinality to 1..n and leave


promotions cardinality as 1..1. You can check the database schema, and
notice that sales_fact 1997 reuses the same promotion_id so its one-tomany and for promotion, promotion id is the primary key so its one-toone.

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

5. To see sample results of a SQL statement using the relationship, click


Relationship SQL tab. It should validate automatically. On the top, youll
see the SQL statement Cognos generated. Click on Test and you should
get the top n rows specified. If nothing shows, something is wrong with
your relationship.

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

6. Do the same for the rest of the query items. Your end result should be the
following:
sales_fact_1997.promotion_id (1..n)

promotion.promotion_id (1..1)

sales_fact_1997.customer_id (1..n)

customer.customer_id (1..1)

sales_fact_1997.store_id (1..n)

store.store_id (1..1)

sales_fact_1997.product_id (1..n)

product.product_id (1..1)

sales_fact_1997.time_id (1..n)

time_by_day.time_id (1..1)

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

product.product_class_id (1..n)

product_class.product_class_id (1..1)

store.region_id (1..n)

region.region_id (1..1)

customer.customer_region_id (1..n)

region.region_id (1..1)

That was easy! You should now have 8 valid relationships.

And your schema should look like the following:

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

Note: The foodmart-reduced data source schema is not the same from the one we
have now. That's because customer has a customer_region_id that is obviously a
foreign key of region. Also, some tables have a foreign key for a table named district,
open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

but it's not in the data source. That's okay. You can just delete it in the next step.

Step 4: Build Business View


In step 3, you created almost the same schema as what you will find in
your database schema, and thats okay, but not for your business users.
You dont want them to work with a database schema. You want to
provide a very basic layout of query subjects for business users so they
can comfortably create queries, and produce reports or workspaces.
Hence the guys at Cognos recommend the:

Three Tier
Design
Physical
View

holds the query subjects and relationships used to build the model.
Query subjects should be unmodified views of the source tables. It's
what you have now.

Business

contains optimized query subjects for use by business users. Query

View

subjects can be by renamed, moved around, consolidated, merged, etc.

Presentation this view will be presented to the business user. Query subjects are
View
organized in a way that business users can understand.

Lets try this with Foodmart-reduced.


1. Right click on the only namespace in the project foodmart-reduced, and Create >
Namespace. Name the namespace, Physical View.
open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

2. Move all subject queries into Physical View namespace. Your project
should be structured like the following:

3. Right click on foodmart-reduced namespace, and Create > Namespace. Name the
namespace, Business View.
4. Right click Business View, and Create > Query Subject.

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

A dialog will appear. Name the subject query, Time and mark it as
a Model query subject. Click OK.

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

Note: The subject queries that were created at the beginning of this recipe
are known as data source query subject which is comparable to a table in SQL.
In the other hand, model query subjects are made from one or more data
source subject queries. This means the query subjects in Physical View should
be data source while the query subjects in Business View should be model.
5. A dialog will open. To the left you will find your project hierarchy. Collapse
Physical View and drag time by day to the white area on the right.
6. Make adjustments like renaming or removing query items for simplicity.
You can do the following:
Remove the following
month_of_year
fiscal_period
open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

SSMA_TimeStamp
Rename the following
the_date

Date

the_day

Day of the Week

the_month

Month

the_year

Year

day_of_month

Day of the Month

week_of_year

Week of the Year

quarter

Quarter

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

7. For Customer repeat step #4, but name the subject query, Customer.
Repeat step #5, but drag customer to the white area on the right and
then at the bottom right-hand corner, click on Add to add a new Query
Item. Name it, Name. From the Available Components white area,
drag fname query item from customer in Physical View to Express
Definition white area to the right. And then drag lname after fname,
separated by + + (excluding double quotes). You can do a lot with
expressions in Cognos. You can check all of their many functions and
parameters by clicking on the tabs on the lower left-hand corner, but we
will cover that some other time. Your final expression definition should
be:
[Physical View].[customer].[fname] + ' ' + [Physical View].[customer].[lname]
To test it, click on the blue play button and it should show you the
correct results like in the picture below:

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

In Customer from Business View namespace:


Remove the following
fname
lname
mi
address2
address3
open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

address4
SSMA_TimeStamp
Rename the following
account_num

Account Number

address1

Address

state_province

State / Province

postal_code

Postal Code

country

Country

phone1

Phone #1

phone2

Phone #2

birthdate

Date of Birth

marital_status

Marital Status

yearly_income

Annual Income

gender

Gender

total_children

Total Children

num_children_at_home

Number of Children at Home

education

Education

date_accnt_opened

Date Account Opened

member_card

Member Card

occupation

Occupation

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

houseowner

House Owner

num_cars_owned

Number of Cars Owned

8. We know the schema in the Physical View namespace is a snowflake,


but we want it simpler and faster. This means less joins: Star schema.
Customer is joined to region, lets merge them. In Query Subject
Definition, collapse Physical View from Available Model Objects and
drag region to Query Items and Calculations. Now you can remove
query items: customer region id and region id since theyre not needed
anymore. Rename the newly imported query items and test to see if it
works.
For organizational purposes, you can put the merged query items in
a folder. The scope still remains the same. Ctrl + Click all merged query
items and then right click on a selected items: New Parent > Query
Item Folder. In this case, you can name it Region.
9. Before we continue to the other data source query subjects, lets fix the
properties for the query items in our Business View. We will focus on one
property setting for query item which is Usage. There are other
important properties that we can talk about on another recipe like
Regular Aggregate, Format, Precision, etc.
A query item can have one of four different usage types:
Icon

open in browser PRO version

Type

When to Use

Identifier

Database key, date/datetime

Fact

Numeric value that can be calculated

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

Attribute / Unknown

Is not an Identifier or Fact, it's an attribute.

With the rule of thumb table above, try to correct the usage type for all
query items in Customer. Some of them are correct already. Property
settings can be found at the bottom of Framework Manager after
selecting a query item.

Take a look at my Customers query item icons and see if it matches


yours:

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

10. Do steps 4-9 for the rest of the query subjects.

Step 5: Build Presentation View


Now that we have created all query subjects for Business View, lets
open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

finish up by creating the Presentation View. In Presentation View, there


will only be shortcut links that point to the query subjects in Business
View. Then well group the shortcut links in a star schema. This allows
you to easily modify what business users see without modifying any of
the query subjects, and when query subjects are modified in the
Business View, changes take effect in the Presentation View as well.
1. Ctrl + Click fact and all dimension subject queries. When all are selected,
right click on one of them, and choose Create Star Schema Grouping

2. Create Star Schema Grouping Dialog will appear. Accept default


open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

settings and name the namespace, 1997 Sales.

3. Right click foodmart-reduced namespace and Create > Namespace.


Name it Presentation View and move 1997 Sales to Presentation
View.

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

Step 6: Publish Package


The content is now ready for the business user to use in the form of a
star schema grouping. Lets publish the Presentation View:
1. Right click on Packages and Create > Package

2. Create Package dialog will appear. Name your package foodmart.


Click Next.

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

3. Now you have to define your objects. The green checkmark means the
object will be included, red X means it will be excluded, and the third
option means its included, but its hidden. We only want business users
to have access to Presentation View, not Physical or Business View, but
we cannot exclude Physical or Business because Presentation depends
on it. Your setting should look like the following image:

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

4. Remember when we created the expression to concatenate first and last


name to a full name query item? Theres a list of functions that you can
use to create more sophisticated expressions when you click the
functions tab. Theres also vendor specific functions that we wont be
using at all except for SQL Server. By default, theyre all included, lets
just keep SQL Server specific functions. Click the top most option in the
list, Shift + Click the bottom most option in the list, Ctrl + Click SQL
Server. Then click the arrow pointing to the left. The lists should look
like the following image and click Finish.
open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

5. You created your package, now you should get a prompt asking if you
want to open the Publishing Package Wizard. Click Yes.

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

6. In Select Location Type window, you need to choose where youre going
to store your package. The typical place to store packages is in Cognos
Content Store. There are two folders in the Content Store you can save
your package or pretty much any file type:
Public
Folders
My Folder

stores files, packages, and folders that is viewable to ALL users.


stores files, packages, and folders that is viewable to ONLY you and
the administrator.

To save it in your My Folder, open the Cognos Content Store explorer:

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

Click on Cognos on the top left corner and choose My Folder:

Click Next twice.


open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

7. Click Publish.

8. By default, Framework Manager verifies packages when theyre published and


alerts you if any errors or warning were found. If you didnt get any warnings or
errors, Congratulations! You successfully published your first, no-error package!

Downloads
Framework Manager Project Example Above

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

Do It Yourself
Create a DMR Model with the FoodMart 2008 db. FoodMart 2008 has
lots of more tables, but dont worry. As long as you create a snowflake or
star schema that has relationships of many-to-one from the inside out,
clean things up, denormalize it, and etc, you should be okay.
Fact Table: inventory_fact 1997
Other Tables: product, product_class, warehouse, and time_by day.

Next Page Simple Report with Graph

Contents
Cognos Express Cookbook
1. About this text
2. Setting Up Data Source
3. Relational Models
a. DMR - Dimensionally Modeled Relational Model
b. Simple Report with Graph
c. Report - Common Techniques
d. Report - with Some Scripting
e. Workspace aka Dashboards
4. Dimensional Models
a. Create TM1 Server
open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

b. Manual Cube Creation


c. Loading Data into Cubes
d. Dimensional Report
5. Tools of the Trade
Contents in Depth
Combined Pages

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

You might also like