第 3 課:處理自行車買主採礦結構
適用於: SQL Server 2016 Preview
在這一課,您將使用 INSERT INTO 陳述式和 vTargetMail 檢視 AdventureWorksDW2012 處理採礦結構和採礦模型中所建立的範例資料庫 第 1 課︰ 建立自行車買主採礦結構 和 第 2 課︰ 將採礦模型加入自行車買主採礦結構。
當您處理採礦結構時,Analysis Services 會讀取來源資料並建立支援採礦模型的結構。 當您處理採礦模型時,採礦結構所定義的資料會透過您選擇的資料採礦演算法來傳遞。 此演算法會搜尋趨勢和模式,然後將此資訊儲存在採礦模型中。 因此,採礦模型不包含實際來源資料,而包含演算法所發現的資訊。 如需有關處理採礦模型的詳細資訊,請參閱 處理需求和考量 #40; 資料採礦 )。
只有當您變更結構資料行或變更來源資料時,才需要重新處理採礦結構。 如果您將採礦模型加入已處理的採礦結構中,您可以使用 INSERT INTO MINING MODEL 陳述式來定型新的採礦模型。
定型結構範本
若要定型採礦結構及其相關聯的採礦模型,使用 INSERT INTO #40; DMX ) 陳述式。 陳述式中的程式碼可分成下列各部份:
識別採礦結構
列出採礦結構中的資料行
定義定型資料
以下是 INSERT INTO 陳述式的一般範例:
INSERT INTO MINING STRUCTURE [<mining structure name>]
(
<mining structure columns>
)
OPENQUERY([<datasource>],'<SELECT statement>')
程式碼的第一行識別您將定型的採礦結構:
INSERT INTO MINING STRUCTURE [<mining structure name>]
程式碼的下一行指定採礦結構定義的資料行。 您必須列出採礦結構的每一個資料行,且每一個資料行必須對應到來源查詢資料內包含的資料行。
(
<mining structure columns>
)
程式碼的最後一行定義將用來定型採礦結構的資料:
OPENQUERY([<datasource>],'<SELECT statement>')
在這一課,您會使用 OPENQUERY 來定義來源資料。 定義來源查詢的其他方法的相關資訊,請參閱 & #60,來源資料查詢 >。
課程工作
您將在這一課執行下列工作:
- 處理自行車買主採礦結構
處理預測採礦結構
若要使用 INSERT INTO 處理採礦結構
在 物件總管] 中, ,以滑鼠右鍵按一下 [執行個體 Analysis Services, ,指向 新查詢, ,然後按一下 [ DMX。
此時會開啟 [查詢編輯器] 且包含新的空白查詢。
將 INSERT INTO 陳述式的一般範例複製到空白查詢中。
取代下列項目:
[<mining structure name>]
成為:
Bike Buyer
取代下列項目:
<mining structure columns>
成為:
[Customer Key], [Age], [Bike Buyer], [Commute Distance], [Education], [Gender], [House Owner Flag], [Marital Status], [Number Cars Owned], [Number Children At Home], [Occupation], [Region], [Total Children], [Yearly Income]
取代下列項目:
OPENQUERY([<datasource>],'<SELECT statement>')
成為:
OPENQUERY([Adventure Works DW], 'SELECT CustomerKey, Age, BikeBuyer, CommuteDistance,EnglishEducation, Gender,HouseOwnerFlag,MaritalStatus, NumberCarsOwned,NumberChildrenAtHome, EnglishOccupation,Region,TotalChildren, YearlyIncome FROM dbo.vTargetMail')
OPENQUERY 陳述式會參考 Adventure Works DW Multidimensional 2012 資料來源來存取 vTargetMail 檢視表。 此檢視包含將用來定型採礦模型的來源資料。
現在,完整的陳述式應該如下所示:
INSERT INTO MINING STRUCTURE [Bike Buyer] ( [Customer Key], [Age], [Bike Buyer], [Commute Distance], [Education], [Gender], [House Owner Flag], [Marital Status], [Number Cars Owned], [Number Children At Home], [Occupation], [Region], [Total Children], [Yearly Income] ) OPENQUERY([Adventure Works DW], 'SELECT CustomerKey, Age, BikeBuyer, CommuteDistance,EnglishEducation, Gender,HouseOwnerFlag,MaritalStatus, NumberCarsOwned,NumberChildrenAtHome, EnglishOccupation,Region,TotalChildren, YearlyIncome FROM dbo.vTargetMail')
在 檔案 ] 功能表上,按一下 [ 另存 DMXQuery1.dmx 為。
在 另存新檔 對話方塊中,瀏覽至適當的資料夾,並將檔案 Process Bike Buyer Structure.dmx。
在工具列上,按一下 [ Execute ] 按鈕。
在下一課,您將探索這一課加入採礦結構中的採礦模型內容。