`
izuoyan
  • 浏览: 8942005 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Mondrian系列(五)-深入维度、层次和级别(4)-维度退化和内联表

 
阅读更多

1.维度退化

维度退化是指对于简单的维度来说,不创建自己的维表,例如,下面的事实表:

product_id time_id payment_method customer_id store_id item_count dollars
55 20040106 Credit 123 22 3 $3.54
78 20040106 Cash 89 22 1 $20.00
199 20040107 ATM 3 22 2 $2.99
55 20040106 Cash 122 22 1 $1.18

对于其中的维度支付方式,假设我们创建了一个维表,这个维表几乎是没有意义的。如果单独增加了这样一个维表,那么可能会导致一定的连接成本。(对于这个问题,我持有不同的看法,例如当这个维度是可被复用时,则这个维表是有意义的)

可以创建一个退化维度,声明一个不包括表的维度,mondrian会假设列来自事实表。看下面的例子:

<cube name="”Checkout”"><br><font color="#ff0000"><!-- 这里声明了事实表 --></font> <br><table name="”checkout”"> <br><dimension name="”Payment" method><br><hierarchy hasall="”true”"><br><font color="#ff0000"><!-- 这里没有声明维表 --></font> <br><level name="”Payment" method column="”payment_method”" uniquemembers="”true”/"><br></level></hierarchy><br></dimension><br> </table> <p>在上面的实例中,因为没有join,Dimension维度的foreignKey属性不需要设置,Hierarchy元素没有</p> <table>子元素或primaryKey属性。 <p>2.内联表</p> <p><inlinetable>构造允许你在schema文件中定义数据集。必须声明列的名字,列的类型,以及一系列的行。作为<table>和<view>,必须提供唯一的别名指向数据集。如下面的例子: <table border="1" cellspacing="0" cellpadding="2" width="775"><tbody><tr> <td valign="top" width="773"> <dimension name="”Severity”"><br><hierarchy hasall="”true”" primarykey="”severity_id”"><br><font color="#ff0000"><inlinetable alias="”severity”"><br></inlinetable></font> <columndefs><br><columndef name="”id”" type="”Numeric”"></columndef><br><columndef name="”desc”" type="”String”"></columndef><br></columndefs><br><rows><br><row><br><value column="”id”">1</value><br><value column="”desc”">High</value><br></row><br><row><br><value column="”id”">2</value><br><value column="”desc”">Medium</value><br></row><br><row><br><value column="”id”">2</value><br><value column="”desc”">Low</value><br></row><br></rows><br><br><level name="”Severity”" column="”id”" namecolumn="”desc”" uniquemembers="”true”/"><br></level></hierarchy><br></dimension><br> </td> </tr></tbody></table> <p>这和你的数据库中有下面的表是一样的效果。</p> <table border="1" cellspacing="0" cellpadding="2" width="600"><tbody> <tr> <td valign="top" width="300">id</td> <td valign="top" width="300">desc</td> </tr> <tr> <td valign="top" width="300">1</td> <td valign="top" width="300">High</td> </tr> <tr> <td valign="top" width="300">2</td> <td valign="top" width="300">Medium</td> </tr> <tr> <td valign="top" width="300">3</td> <td valign="top" width="300">Low</td> </tr> </tbody></table> <p>要指定某个列NULL值,对那个列忽略<value>,列的值默认为空。</value></p> <p>3.估计Level的势</p> <p><level>元素允许指定可选的参数 "approxRowCount",指定这个参数可以改善性能,通过减少需要决定的level,层次和维度的势。通过连接到XMLA的Mondrian,可能会产生较大的影响。</level></p></view> </table></inlinetable></p> </table></cube>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics