一、維表、事實表
(1)維是透視或關於一個組織想要記錄的實體,描述試題的元信息。如:item:item 的維表可以包含屬性item_name, branch, 和type。維表可以由用戶或專家設定,或者根據數據分布自動產生和調整(即從事實表中抽取維度表)
(2)事實是數值度量的。如:事實表sales包括dollars_sold, units_sold 和amount_budgeted,也可以說是指標值。事實表包括事實的名稱或度量,以及每個相關維表的關鍵字(索引)
二、星型、雪花型與事實星座:多維數據庫模式
(1)星型:一種非正規化的結構,多維數據集的每一個維度都直接與事實表相連接,不存在漸變維度,所以數據有一定的冗余。

(2)雪花型:雪花模型是對星型模型的擴展。它對星型模型的維表進一步層次化,原有的各維表可能被擴展為小的事實表,形成一些局部的 "層次 " 區域,這些被分解的表都連接到主維度表而不是事實表,通過最大限度地減少數據存儲量以及聯合較小的維表來改善查詢性能。雪花型結構去除了數據冗余。

(3)事實星座:又稱星系模式,復雜的應用可能需要多個事實表共享維表。這種模式可以看作星形模式集。

三、數據挖掘查詢語言:DMQL
(1)數據倉庫和數據集市可以使用兩種原語定義:一種是方定義,一種是維定義。方定義語句具有
如下語法形式:
- define cube <cube_name> [<dimension_list>] : <measure_list>
(2)維定義語句具有如下語法形式:
- define dimension <dimension_name> as (<attribute_or_subdimension_list>)
例子說明:
(1)圖一定義的星形模式用DMQL 定義如下:
- define cube sales_star [time, item, branch, location]:
- dollars_sold = sum(sales_in_dollars), units_sold = count(*)
- define dimension time as (time_key, day, day_of_week, month, quarter, year)
- define dimension item as (item_key, item_name, brand, type, supplier_type)
- define dimension branch as (branch_key, branch_name, branch_type)
- define dimension location as (location_key, street, city, province_or_state, country)<span style="font-family: Arial;">
- define cube 語句定義一個方,叫做sales_star,它對應於例2.1 的中心表sales 事實表。該命令
- 說明維表的關鍵字和兩個度量,dollars_sold 和units_sold。數據方具有四個維,分別為time, item,
- branch 和location。一個define dimension 語句定義一個維。</span>
(2)圖2定義的雪花模式用DMQL 定義如下:
- define cube sales_snowflake [time, item, branch, location]:
- dollars_sold = sum(sales_in_dollars), units_sold = count(*)
- define dimension time as (time_key, day, day_of_week, month, quarter, year)
- define dimension item as (item_key, item_name, brand, type, supplier(supplier_key, supplier_type))
- define dimension branch as (branch_key, branch_name, branch_type)
- define dimension location as (location_key, street, city(city_key, city, province_or_state, country))
在sales_snowflake 數據方中,sales_star 數據方的item 維被規范化成兩個維表,item 和supplier。注意:
supplier 的維定義在item 的定義中說明。用這種方式定義supplier,隱式地在item 的定義中創建了
一個supplier_key。類似地,在sales_snowflake 數據方中,sales_star 數據方的location 維被規范化成
兩個維表,location 和city。city 的維定義在location 的定義中說明。用這種方式,city_key 在location
的定義中隱式地創建。
(3)圖3定義的星座模式用DMQL 定義如下:
- define cube sales [time, item, branch, location]:
- dollars_sold = sum(sales_in_dollars), units_sold = count(*)
- define dimension time as (time_key, day, day_of_week, month, quarter, year)
- define dimension item as (item_key, item_name, brand, type, supplier_type)
- define dimension branch as (branch_key, branch_name, branch_type)
- define dimension location as (location_key, street, city, province_or_state, country)
- define cube shipping [time, item, shipper, from_location, to_location]:
- dollars_sold = sum(cost_in_dollars), units_sipped = count(*)
- define dimension time as time in cube sales
- define dimension item as item in cube sales
- define dimension shipper as (shipper_key, shipper_name, location as location in cube sales,shipper_type)
- define dimension from_location as location in cube sales
- define dimension to_location as location in cube sales
define cube 語句用於定義數據方sales 和shipping,分別對應於圖3 模式的兩個事實表。注意,
數據方sales 的time, item 和location 維可以與數據方shpping 共享。例如,time 維,在定義數據方
shipping 語句之下,用“define dimension time as time in cube sales”說明。
四、度量:分類與計算
(1)分布的:
一個聚集函數是分布的,如果它能以如下分布方式進行計算:設數據被划分為n 個集合,函數在每一部分上的計算得到一個聚集值。如果將函數用於n 個聚集值得到的結果,與將函數用於所有數據得到的結果一樣,則該函數可以用分布方式計算。例如,count()可以這樣計算:首先將數據方分割成子方的集 合,對每個子方計算count(),然后對這些子方得到的計數求和。因此,count()是分布聚集函數。同理,sum(), min()和max()是分布聚集函數。一個度量是分布的,如果它可以用分布聚集函數得到。
(2)代數的
一個聚集函數是代數的,如果它能夠由一個具有M(其中,M 是一個整數界)個參數的代數函數計算,而每個參數都可以用一個分布聚集函數求得。例如,avg()可以由sum()/count()計算,其中sum() 和count()是分布聚集函數。類似地,可以表明min_N(), max_N()和standard_deviation()是代數聚集函數。一個度量是代數的,如果它可以用代數聚集函數得到。
(3)整體的
一個聚集函數是整體的,如果描述它的子聚集所需的存儲沒有一個常數界。即,不存在一個具有M個(其中,M是常數)參數的代數函數進行這一計算。整體函數的 常見例子包括median(),mode()(即,最常出現的項),和rank()。一個度量是整體的,如果它可以用整體聚集函數得到。
五、DMQL翻譯
設關系數據庫模式如下:
- time(time_key, day, day_of_week, month, quarter, year)
- item(item_key, item_name, branch, type)
- branch(branch_key, branch_name, branch_type)
- location(location_key, street, city, province_or_state, country)
- sales(time_key, item_key, branch_key, location_key, number_of_units_sold, price)
例1中DMQL 說明被翻譯成如下SQL 查詢,這些查詢產生所需要的sales_star 數據方。這里,聚集函數sum 用於計算dollars_sold 和units_sold:
- select s.time_key, s.item_key, s.branch_key, s.location_key,
- sum(s.number_of_units_sold*s.price), sum(s.number_of units_sold)
- from time t, item i, branch b, location l, sales s
- where s.time_key=t.time_key and s.item_key=i.item_key
- and s.branch_key=b.branch_key and s.location_key=l.location_key
- group by s.time_key,s.item_key,s.branch_key,s.location_key

