Determinants – The Answer to a Framework Manager Mystery

2024-01-13 15:38

本文主要是介绍Determinants – The Answer to a Framework Manager Mystery,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

以前一直对Determinants很困惑,发现了一篇文章解释的很清楚,分享一下。原文Determinants – The Answer to a Framework Manager Mystery

Determinants can play a crucial role in the overall performance and consistency of your Framework Manager model but remain one of the most confusing aspects of the application to most developers. This article will attempt to end the confusion.

Determinants are used so that a table of one grain (level of detail) behaves as if it were another actually stored at another grain. They are primarily used for dimension tables where fact tables join to dimension tables at more than one level in the dimension. (There are other cases where you could use them, but they are less common and fairly specific situations.)

The Situation

Let’s use the example of a date dimension table with day level grain. If all the fact tables join at the day level, the most detailed level, then you do not need determinants.  But as many of us know from experience, this is not always the case. Fact table are often aggregated or stored at different levels of granularity from a number of reasons.

The Problem

The trouble arises when you wish to join to the dimension table at a level that is not the lowest level. Consider a monthly forecast fact table which is at the month level of detail (1 row per month). A join to the month_id (e.g. 2009-12) would return 28 to 31 records (depending on the month) from the date dimension, and throw off the calculations. Determinants solve this problem.

The SQL

Often when modeling, it’s useful to think about the SQL code you would like to generate. Without determinants, the incorrect SQL code would look something like this.

SELECT
F.FORCAST_VALUE,
D.MONTH_ID,
D.MONTH_NAME
FROM SALES_FORECAST F INNER JOIN DATE_DIM D ON
F.MONTH_ID = D.MONTH_ID

This code will retrieve up to 31 records for each of the sales forecast records. Applying mathematical functions, for example Sum and Count, would produce an incorrect result. What you would like to generate is something along the following lines, which creates a single row per month, AND THEN join to the fact table.

SELECT
F.FORCAST_VALUE,
D1.MONTH_ID,
D1.MONTH_NAME
FROM SALES_FORECAST F INNER JOIN
( SELECT DISTINCT
D.MONTH_ID,
D.MONTH_NAME
FROM DATE_DIM D ) AS D1
ON F.MONTH_ID = D1.MONTH_ID

As shown  above, the trick is to understand which columns in the dimension table are related to the month_id, and therefore are unique along with the key value.  This is exactly what determinants do for you.

Unraveling the Mystery in Framework Manager

Following Cognos best practices, determinants should be specified at the layer in the model in which the joins are specified.

Here we see a date dimension with 4 levels in the dimension, Year, Quarter, Month and day level.

1

This means we can have up to 4 determinants defined in the query subject depending on the granularity of the fact tables present in your model.  The first three levels, Year, Quarter, Month, should be set to “group-by” as they do not define a unique row within the table and Framework Manager needs to be made aware that the values will need to be “Grouped” to this level. In other words, the SQL needs to “group by” a column or columns in order to uniquely identify a row for that level of detail (such as Month or Year).  The Day level (often called the leaf level) should be set to “Uniquely Identified”, as it does uniquely identify any row within the dimensional table. While there can be several levels of “group by” determinants, there is typically only one uniquely identified determinant, identified by the unique key of the table. The “uniquely identified” determinant by definition contains all the non-key columns as attributes, and is automatically set at table import time, if it can be determined.

The Key section identifies the column or columns which uniquely identify a level.  Ideally, this is one column, but in some cases may actually need to include more than one column.  For example, if your Year and Month values (1-12) are in separate columns.  In short, the key is whatever columns are necessary to uniquely identify that level.

Using our aforementioned table, the setup would look like this:

2

The Attributes section identifies all the other columns which are distinct at that level.  For example, at a month_id  (e.g. 2009-12) level , columns such as month name, month starting date, number of days in a month are all distinct at that level. And obviously items from a lower level, such as date or day-of-week, are not included at that level.

Technically, the order of the determinants does not imply levels in the dimension. However, columns used in a query are matched from the top down which can be very important to understanding the SQL that will be generated for your report. If your report uses Year, Quarter and Month, the query will group by the columns making up the Year-key, Quarter-key and Month-key. But if the report uses just Year and Month (and not the Quarter) then the group by will omit the Quarter-key.

How Many Levels Are Needed?

Do we need all 4 levels of determinants? Keep in mind that determinants are used to join to dimensions at levels higher than the leaf level of the dimension. In this case, we’re joining at the month level (via month_id). Unless there are additional joins at the year or quarter level, we do not strictly need to specify those determinants. Remember that year and quarter are uniquely defined by the month_id as well, and so should be included as attributes related to the month, as shown.

3

The Result

Following these simple steps the following SQL will be generated for your report. The highlighted section is generated by the determinant settings. Notice how it groups by the Month_ID, and uses themin function to guarantee uniqueness at that level.  (No, it doesn’t trust you enough to simply do a SELECT DISTINCT.)  The second level of group by is the normal report aggregation by report row.  So the result is that the join is done correctly, which each monthly fact record joined to 1 dimensional record at the appropriate level, to produce the correct values in the report.

4

 

 

 

这篇关于Determinants – The Answer to a Framework Manager Mystery的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/601961

相关文章

Spring Framework系统框架

序号表示的是学习顺序 IoC(控制反转)/DI(依赖注入): ioc:思想上是控制反转,spring提供了一个容器,称为IOC容器,用它来充当IOC思想中的外部。 我的理解就是spring把这些对象集中管理,放在容器中,这个容器就叫Ioc这些对象统称为Bean 用对象的时候不用new,直接外部提供(bean) 当外部的对象有关系的时候,IOC给它俩绑好(DI) DI和IO

ORACLE 11g 创建数据库时 Enterprise Manager配置失败的解决办法 无法打开OEM的解决办法

在win7 64位系统下安装oracle11g,在使用Database configuration Assistant创建数据库时,在创建到85%的时候报错,错误如下: 解决办法: 在listener.ora中增加对BlueAeri-PC或ip地址的侦听,具体步骤如下: 1.启动Net Manager,在“监听程序”--Listener下添加一个地址,主机名写计

Oracle Enterprise Manager:Oracle数据库管理的高效工具

在数据库管理和维护中,Oracle Enterprise Manager(OEM)是一个强大的工具,它提供了一个集中的平台来监控、管理和优化Oracle数据库环境。通过使用Oracle Enterprise Manager,数据库管理员可以提高效率、减少手动干预并确保数据库系统的稳定性和性能。本文将详细介绍如何在Oracle中使用Oracle Enterprise Manager,包括其主要功能、

Oracle(110)什么是RMAN(Recovery Manager)?

RMAN(Recovery Manager)是Oracle数据库提供的一个高效的备份和恢复工具。它能够简化和自动化复杂的备份和恢复操作,并且提供了强大的功能来确保数据的完整性和安全性。 RMAN 的主要功能 备份数据库:支持全备份、增量备份和归档日志备份。恢复数据库:支持从备份中恢复整个数据库或部分数据。克隆数据库:可以方便地创建数据库的副本。验证备份:确保备份数据的一致性和完整性。管理备份空

安卓aosp14上自由窗口划线边框Freeform Caption实战开发-千里马framework实战

背景: 上一篇文章也分享过aosp14版本上自由窗口的Caption栏的显示原理,今天来讲解一下aosp14版本上如何实现对自由窗口的划线边框功能,相关功能已经在aosp13上面进行实现,具体可以看我的分屏自由窗口专题哈。 就是想要在aosp14上面实现如下功能: 即自由窗口在被触摸放大缩小时候,边框要被画成红色的线条,表示选中。 尝试aosp13老方案: 因为aosp13是在acti

SOMEIP_ETS_088: SD_Answer_multiple_subscribes_together

测试目的: 验证设备(DUT)是否能够接受它接收到的每个SubscribeEventgroup条目。 描述 本测试用例旨在检查DUT在接收到包含多个SubscribeEventgroup条目的消息时,是否能够为每个条目发送SubscribeEventgroupAck。 测试拓扑: 具体步骤: TESTER:发送包含多个SubscribeEventgroup条目的消息,用于事件组:

Android Framework中的PolicyManager简介

PolicyManager类位于framework\base\core\java\com\android\internal\policy目录中的PolicyManager.java文件中。PolicyManager主要用于创建Window类、LayoutInflater类和WindowManagerPolicy类,它扮演着简单工厂模式中的工厂类角色,而抽象产品角色由IPolicy接口实现,具体产

知识图谱(knowledge graph)——RDF(Resource Description Framework)

RDF的基本单元是三元组(triple) 每个三元组是(主语 谓语 宾语) 这样的元组tuple。主谓宾的取值称为"资源"(Resource, 也就是RDF里的R) 资源可以是一个网址(URI),一个字符串或数 字(严格来讲都是带类型的字符串,称为 literal),或者一个“空节点”(blank node)。 有两种特殊类型的资源。rdfs:Class代表类。 rdf:Property代

【持续更新】Advanced Download Manager 14.0.35 Pro安卓ADM下载神器最新高级免费修改版

这个也算小有名气,名字和 idm 有点像。当程序从剪贴板中截取链接后,您可以将其复制并发送至ADM编辑器,或者使用“添加”按钮粘贴链接。 ▨ ADM 有以下特点: • 该应用支持同时下载最多三个文件 • 通过多线程技术(9个部分)加速下载过程 • 从安卓浏览器及剪贴板中拦截链接 • 后台下载文件,并在失败后自动恢复 • 支持图片、文档、压缩包及程序的加载 • 针对Lollipop和Ma

Xcode8安装package manager

从Xcode7升级到Xcode8,或者直接从官网下载安装Xcode8的同学肯定会发现我们熟悉的插件都不能用了。原来window选项卡下有package manager栏目,但Xcode8变没有了。不要捉急,有办法可以让它出来。具体操作如下: 1.打开terminal输入​install update_xcode_plugins ​当你看到这个情况的时候说明你安装失败了,具体