1.什么是星座模型?

2.哪些地方可以用到星座模型?

3.Mondrian怎么构建星座模型,构建过程又涉及到哪些理论概念。

答1:这里描述了维度模型常用的 星型、雪花、星座模型,简而言之就是多事实表模型。

[转载] 第二篇 数据仓库与数据集市建模

答2:例如有个场景,通过资产负债及损益表计算应收款周转天数。其中资产负债表和损益表都有对应单独的数据视图

计算公式如下:

应收款周转天数 = 360/(([Total 本期发生数],[营业收入])/(([Total 年初数],[应收账款])+([Total 期末数],[应收账款]))/2)

=360/损益表中项目为[营业收入]的本期发生数合计 /(资产负债表中项目为[应收账款]的年初数合计+年末数合计)/2

=360/损益表中项目为[营业收入]的本期发生数合计 /(资产负债表中项目为[应收账款]的年平均数

为了实现上述统计,如果使用传统物理模型去串表则容易产生数据冗余的情况。具体如何冗余自己脑补一下吧。为了解决上述问题则通过建立逻辑模型进行计算处理。

答3:

Mondrian实现理论上的星座模型过程涉及到哪些概念呢?见下图

1.退化维度的概念参考这里

维度-退化维度

组织这里为什么会被称为退化维度?因为在资产负债视图中,已经包含了组织编码和组织名称字段,不需要另外串表来实现,所以叫退化维度。基本一个资产负债视图事实表就替代了N个维度表。

见SQL查询资产负债视图

select * from 资产负债视图

2.共享维度的概念参考这里:

维度-共享维度

模型中建立了年度的共享维度,并在资产负债视图、损益视图都调用了年度共享维度。

实现方法就是在需要使用共享维度的Cube外面建一个维度,然后在各个Cube需要引用共享维度的使用添加对共享维度的引用。

为了模拟方便,手工建立了年度、月度的维度表

 create Table 年表
(
id int,
年度 int
) create Table 月表
(
id int,
FYEARID int,
月份 int
) insert into 年表(id,年度)
select 1,2018
union all
select 2,2019 insert into 月表(id,FYEARID,月份)
select 1,1,1
union all
select 2,1,2
union all
select 3,1,3
union all
select 4,1,4
union all
select 5,1,5
union all
select 6,1,6
union all
select 7,1,7
union all
select 8,1,8
union all
select 9,1,9
union all
select 10,1,10
union all
select 11,1,11
union all
select 12,1,12 select * from 年表
select * from 月表 insert into 月表(id,FYEARID,月份)
select 21,2,1
union all
select 22,2,2
union all
select 23,2,3
union all
select 24,2,4
union all
select 25,2,5
union all
select 26,2,6
union all
select 27,2,7
union all
select 28,2,8
union all
select 29,2,9
union all
select 30,2,10
union all
select 31,2,11
union all
select 32,2,12

3.重点就是建立虚拟立方体了,

其实这里虚拟立方体就是星座模型的载体。

Mondrain官方给了虚拟立方体的解释(Virtual OLAP Cubes) https://help.pentaho.com/Documentation/7.1/0N0/020/040/000

另外一个老外那里给了虚拟立方体的定义案例可以参考 https://diethardsteiner.github.io/mondrian/2017/03/20/Mondrian-Multivalued-Dimension-Attribute.html

其实前面的准备工作做好了,后面建立虚拟立方体的工作就很简单了。

首先,命名

然后加入共享维度,注意共享维度不需要填写 cubeName。

最后是调用资产负债Cube和损益Cube的度量值

例如:调用资产负债Cube的年初数度量值,cubeName选择资产负债Cube的名称【BalanceCube】。

而name这里写法,[注意]、[注意]、[注意],必须先填写前缀 [Mesures].  再加上各个Cube的度量值名称,外面加上中括号[]。

资产负债的年初数度量值写法应该是

[Mesures].[NCS]

损益的本期发生数写法则应该是

[Mesures].[BQFSS]

保存,上传到Saiku,预览一下模型。

至此,通过Mondrian构建星座模型的工作已成功完成,具体自己调整可以继续。

附上Schema文件

<Schema name="FinSchema" description="财务模式" measuresCaption="财务模式">
<Dimension type="StandardDimension" visible="true" name="年度">
<Hierarchy visible="true" hasAll="true" allMemberName="所有年度" allMemberCaption="所有年度" primaryKey="年度">
<Table name="年表" schema="dbo" alias="">
</Table>
<Level name="年度" visible="true" column="年度" nameColumn="年度" type="Integer" uniqueMembers="false">
</Level>
</Hierarchy>
</Dimension>
<Cube name="BalanceCube" caption="资产负债Cube" visible="true" description="资产负债Cube" cache="true" enabled="true">
<Table name="资产负债视图" schema="dbo">
</Table>
<Dimension type="StandardDimension" visible="true" highCardinality="false" name="组织" caption="组织编码">
<Hierarchy visible="true" hasAll="true" allMemberName="所有组织" allMemberCaption="所有组织">
<Level name="组织编码" visible="true" column="组织编码" nameColumn="组织名称" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
</Level>
<Level name="组织名称" visible="true" column="组织名称" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
</Level>
</Hierarchy>
</Dimension>
<Dimension type="StandardDimension" visible="true" highCardinality="false" name="账簿">
<Hierarchy name="BookHierarchy" visible="true" hasAll="true" allMemberName="所有账簿" allMemberCaption="所有账簿">
<Level name="账簿名称" visible="true" column="账簿名称" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
</Level>
</Hierarchy>
</Dimension>
<Dimension type="StandardDimension" visible="true" highCardinality="false" name="项目分类">
<Hierarchy name="ItemTypeHierarchy" visible="true" hasAll="true" allMemberName="所有分类" allMemberCaption="所有分类">
<Level name="项目分类" visible="true" column="项目分类" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
</Level>
</Hierarchy>
</Dimension>
<Dimension type="StandardDimension" visible="true" highCardinality="false" name="项目名称">
<Hierarchy name="ItemHierarchy" visible="true" hasAll="true" allMemberName="所有项目" allMemberCaption="所有项目">
<Level name="项目名称" visible="true" column="项目名称" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
</Level>
</Hierarchy>
</Dimension>
<DimensionUsage source="年度" name="年度" visible="true" foreignKey="年">
</DimensionUsage>
<Measure name="NCS" column="年初数" aggregator="sum" visible="true">
</Measure>
<Measure name="QMS" column="期末数" aggregator="sum" visible="true">
</Measure>
</Cube>
<Cube name="ProfitCube" caption="利润Cube" visible="true" description="利润Cube" cache="true" enabled="true">
<Table name="损益视图" schema="dbo">
</Table>
<Dimension type="StandardDimension" visible="true" highCardinality="false" name="组织">
<Hierarchy visible="true" hasAll="true" allMemberName="所有组织" allMemberCaption="所有组织">
<Level name="组织编码" visible="true" column="组织编码" nameColumn="组织编码" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
</Level>
<Level name="组织名称" visible="true" column="组织名称" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
</Level>
</Hierarchy>
</Dimension>
<Dimension type="StandardDimension" visible="true" highCardinality="false" name="账簿">
<Hierarchy visible="true" hasAll="true" allMemberName="所有账簿" allMemberCaption="所有账簿">
<Level name="账簿名称" visible="true" column="账簿名称" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
</Level>
</Hierarchy>
</Dimension>
<Dimension type="StandardDimension" visible="true" highCardinality="false" name="项目名称">
<Hierarchy visible="true" hasAll="true" allMemberName="所有项目名称" allMemberCaption="所有项目名称">
<Level name="项目名称" visible="true" column="项目名称" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
</Level>
</Hierarchy>
</Dimension>
<DimensionUsage source="年度" name="年度" visible="true" foreignKey="年">
</DimensionUsage>
<Measure name="BQFSS" column="本期发生数" datatype="Numeric" aggregator="sum" visible="true">
</Measure>
</Cube>
<VirtualCube enabled="true" name="BPCube" description="财务资产负债损益模型">
<VirtualCubeDimension name="年度">
</VirtualCubeDimension>
<VirtualCubeMeasure cubeName="BalanceCube" name="[Measures].[NCS]" visible="true">
</VirtualCubeMeasure>
<VirtualCubeMeasure cubeName="ProfitCube" name="[Measures].[BQFSS]" visible="true">
</VirtualCubeMeasure>
</VirtualCube>
</Schema>
 
其实度量值可以用中文标示

使用Mondrian Virtual OLAP Cube 实现星座模型并在saiku展现分析的更多相关文章

  1. 在Mondrian Virtual OLAP Cube中观察星座模型多事实表度量值的聚合

    这样设置的Schema文件会怎么样呢?用Saiku预览一下. 如果这时候想同时引用两个项目进行计算就会出问题了.那么这种情况怎么解决? 参考网上一段实现思路 <VirtualCube name= ...

  2. C1WPF制作OLAP Cube浏览工具

    经过前期一段时间对WPF的学习了解,相信大家对WPF有了一定的了解.今天我们一起来了解使用Component One(简称C1)的WPF控件制作CUBE浏览工具.其实这个OLAP控件官方已经有了很详细 ...

  3. JPMML解析PMML模型并导入数据进行分析生成结果

    JPMML解析Random Forest模型并使用其预测分析 导入Jar包 maven 的pom.xml文件中添加jpmml的依赖 <dependency> <groupId> ...

  4. YII用户注冊和用户登录(三)之模型中规则制定和分析

    3 模型中规则制定和分析 YII模型主要分为两类,一个数据模型,处理和数据库相关的增删改查.继承CActiveRecord.还有一个是表单模型,继承CFormModel.不与数据库进行交互.操作与数据 ...

  5. [iTyran原创]iPhone中OpenGL ES显示3DS MAX模型之一:OBJ格式分析

    [iTyran原创]iPhone中OpenGL ES显示3DS MAX模型之一:OBJ文件格式分析作者:yuezang - iTyran     在iOS的3D开发中常常需要导入通过3DS MAX之类 ...

  6. 【原创】linux设备模型之kset/kobj/ktype分析

    背 景 Read the fucking source code! --By 鲁迅 A picture is worth a thousand words. --By 高尔基 说明: Kernel版本 ...

  7. OLAP引擎:基于Presto组件进行跨数据源分析

    一.Presto概述 1.Presto简介 Presto是一个开源的分布式SQL查询引擎,适用于交互式分析查询,数据量支持GB到PB字节,Presto虽然具备解析SQL的能力,但它并不属于标准的数据库 ...

  8. 最大熵模型(Maximum Entropy Models)具体分析

    因为本篇文章公式较多,csdn博客不同意复制公式,假设将公式一一保存为图片在上传太繁琐了,就用word排好版后整页转为图片传上来了.如有错误之处.欢迎指正.

  9. Java内存模型之从JMM角度分析DCL

    DCL,即Double Check Lock,中卫双重检查锁定.其实DCL很多人在单例模式中用过,LZ面试人的时候也要他们写过,但是有很多人都会写错.他们为什么会写错呢?其错误根源在哪里?有什么解决方 ...

随机推荐

  1. oracle 中时间类型 date 与 long 互转

    我们在保存时间到数据库时,有时候会保存long型的数据,固定长度是13位,是用当前时间减去1970-01-01,再换算成毫秒得到的结果. 但是要考虑到时区问题中国的时区时+8区所以时间要加上8小时 o ...

  2. vs + wsl .net core 远程调试 (linux vsdbg)

    https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes https://github.com/ ...

  3. 扩展JPA方法,重写save方法

    为什么要重构save? jpa提供的save方法会将原有数据置为null,而大多数情况下我们只希望跟新自己传入的参数,所以便有了重写或者新增一个save方法. 本着解决这个问题,网上搜了很多解决方案, ...

  4. python str, list,tuple, dir

    Python3 字符串 字符串是 Python 中最常用的数据类型.我们可以使用引号('或")来创建字符串. 创建字符串很简单,只要为变量分配一个值即可.例如: var1 = 'Hello ...

  5. BBS项目之后台管理

    一:后台管理,添加文章样式编写 创建 一个后台管理模板前段页面 <!DOCTYPE html> <html lang="en"> <head> ...

  6. (3)WePHP控制器与模型

    MVC的先进理念就是程序流程 数据库操作 模板制作三个流程分离 大M函数会把模型引入到当前控制器的方法中,注意这个"excel"对应M文件夹的excel.php 同时也是整个exc ...

  7. iOS Programming Recipe 6: Creating a custom UIView using a Nib

    iOS Programming Recipe 6: Creating a custom UIView using a Nib JANUARY 7, 2013 BY MIKETT 12 COMMENTS ...

  8. critical section的用法

    critical section Critical Section: 不论是硬件临界资源,还是软件临界资源,多个进程必须互斥地对它进行访问.每个进程中访问临界资源的那段代码称为临界区(Critical ...

  9. 团体程序设计天梯赛L2-013 红色警报 2017-03-23 22:08 55人阅读 评论(0) 收藏

    L2-013. 红色警报 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 战争中保持各个城市间的连通性非常重要.本题要求你编写一 ...

  10. 异步IO类

    也学习多线程一段时间了,也写了几个简单实用的功能类,也意思到细节的处理的重要性,现在就让我们来写一个稍稍更有用的异步IO的类. 本来想参考Java NIO 中的类,Java NIO作为新io包,本身提 ...