安裝了saiku以後,每次修改schema文件,很是耗時,每次都要經歷若干步驟:修改xml、上傳、重啓才能生效,而且很是不利於學習和理解MDX和模式文件,躊躇之際,發現了這個工具,十分小巧方便!saiku安裝過程可參考上一篇博客:http://www.cnblogs.com/liqiu/p/5183894.htmlhtml
這是一個pentaho的一個工具,有不少版本,下載地址:https://sourceforge.net/projects/mondrian/files/schema%20workbench/3.11.0/linux
下載以後,執行裏面的啓動命令便可,windows執行:workbench.bat;linux執行:workbench.sh。我使用的是mac,效果如圖:sql
運行這款軟件確定依賴一個數據庫,Mysql或者Postgresql均可以,我使用的是PostgreSql,下面是網絡上搜索到的建表語句:數據庫
CREATE TABLE sale ( saleid integer NOT NULL, proid integer, cusid integer, unitprice double precision, num integer, CONSTRAINT sale_pkey PRIMARY KEY (saleid) ); CREATE TABLE customer ( cusid integer NOT NULL, gender character(1), CONSTRAINT customer_pkey PRIMARY KEY (cusid) ); CREATE TABLE product ( proid integer NOT NULL, protypeid integer, proname character varying(32), CONSTRAINT product_pkey PRIMARY KEY (proid) ); CREATE TABLE producttype ( protypeid integer NOT NULL, protypename character varying(32), CONSTRAINT producttype_pkey PRIMARY KEY (protypeid) ); insert into Customer(cusId,gender) values(1,'F') insert into Customer(cusId,gender) values(2,'M') insert into Customer(cusId,gender) values(3,'M') insert into Customer(cusId,gender) values(4,'F') insert into producttype(proTypeId,proTypeName)values(1,'電器') insert into producttype(proTypeId,proTypeName)values(2,'數碼') insert into producttype(proTypeId,proTypeName)values(3,'傢俱') insert into product(proId,proTypeId,proName)values(1,1,'洗衣機') insert into product(proId,proTypeId,proName)values(2,1,'電視機') insert into product(proId,proTypeId,proName)values(3,2,'mp3') insert into product(proId,proTypeId,proName)values(4,2,'mp4') insert into product(proId,proTypeId,proName) values(5,2,'數碼相機') insert into product(proId,proTypeId,proName)values(6,3,'椅子') insert into product(proId,proTypeId,proName)values(7,3,'桌子') insert into sale(saleId,proId,cusId,unitPrice,number)values(1,1,1,340.34,2) insert into sale(saleId,proId,cusId,unitPrice,number)values(2,1,2,140.34,1) insert into sale(saleId,proId,cusId,unitPrice,number)values(3,2,3,240.34,3) insert into sale(saleId,proId,cusId,unitPrice,number)values(4,3,4,540.34,4) insert into sale(saleId,proId,cusId,unitPrice,number)values(5,4,1,80.34,5) insert into sale(saleId,proId,cusId,unitPrice,number)values(6,5,2,90.34,26) insert into sale(saleId,proId,cusId,unitPrice,number)values(7,6,3,140.34,7) insert into sale(saleId,proId,cusId,unitPrice,number)values(8,7,4,640.34,28) insert into sale(saleId,proId,cusId,unitPrice,number)values(9,6,1,140.34,29) insert into sale(saleId,proId,cusId,unitPrice,number)values(10,7,2,740.34,29) insert into sale(saleId,proId,cusId,unitPrice,number)values(11,5,3,30.34,28) insert into sale(saleId,proId,cusId,unitPrice,number)values(12,4,4,1240.34,72) insert into sale(saleId,proId,cusId,unitPrice,number)values(13,3,1,314.34,27) insert into sale(saleId,proId,cusId,unitPrice,number)values(14,3,2,45.34,27)
點擊下面右下腳的圖標:windows
配置數據庫連接:網絡
我選擇的是PostgreSql,確認便可ide
5.1 建立空的schema工具
5.2 修改schema名稱,命名是:qiu-schema學習
5.3 添加立方體測試
命名是:qiu-cube
5.4 在立方體裏面添加事實表
5.5 在立方體裏面添加維度:qiuDimension
5.6 在維度下面,添加層次。其實不須要添加,他會默認添加一下,點擊qiuDimension左側的小圖標便可
5.7 在qiu-Hierarchy下面添加維度表,我們選擇的是customer
5.8 繼續添加一個層次:qiuLevel
到這裏最困難的都已經完成了
5.9 添加度量
到這裏一個簡單的模式文件就建成了,點擊最右側的帶有鉛筆樣式的圖標便可看見xml文件:
<Schema name="qiu-schema"> <Cube name="qiu-cube" visible="true" cache="true" enabled="true"> <Table name="sale" schema="public" alias=""> </Table> <Dimension type="StandardDimension" visible="true" foreignKey="cusid" name="qiuDimension"> <Hierarchy name="qiuHierarchy" visible="true" hasAll="true" allMemberName="allCustomer" allMemberCaption="所有名称"> <Table name="customer" schema="public" alias=""> </Table> <Level name="qiuLevel" visible="true" column="gender" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never"> </Level> </Hierarchy> </Dimension> <Measure name="qiuMeasure" column="num" datatype="Numeric" aggregator="sum" visible="true"> </Measure> </Cube> </Schema>
若是上面有遺漏的部分,把這個xml文件替換進去,從新點擊鉛筆樣式的圖標便可充新生成
選擇File,在選擇MDX Query,便可建立查詢對話框,插入以下語句:
select {[Measures].qiuMeasure} on columns, {([qiuDimension].[allCustomer])} on rows from [qiu-cube]
效果如圖: