mondrian schema Closure Table

Closure Table 很好的解决了父子关系层次问题,就是说每一个成员只有一个父成员,而不必管它上层的成员。

employee
supervisor_id employee_id full_name
null 1 Frank
1 2 Bill
2 3 Eric
1 4 Jane
3 5 Mark
2 6 Carla

上表描述了员工与导师之间的关系,mondrian通过引用closure table来解决访问它的问题。(网页上说普通的方法比较慢)

employee_closure
supervisor_id employee_id distance
1 1 0
1 2 1
1 3 2
1 4 1
1 5 3
1 6 2
2 2 0
2 3 1
2 5 2
2 6 1
3 3 0
3 5 1
4 4 0
5 5 0
6 6 0

上面的表描述了节点与节点之间的距离

这样就可以通过6 访问2,4;通过2访问6,3;通过3访问5了。

具体的数据库设计,schema文件设计参见(http://forums.pentaho.org/showthread.php?t=73017

原文地址:https://www.cnblogs.com/iammatthew/p/1803902.html