Showing posts with label examples. Show all posts
Showing posts with label examples. Show all posts

Sunday, March 25, 2012

Do I need multiple versions of Northwind?

I am learning SQL Server 2005 Express, and want to use the Northwind data base as used in many code examples. I wanted to attach the Northwind data base via SQL Management Studio, but cannot find a Northwind.mdf file.

When I do a search using 'Northwind', I see there are already a couple of different versions of Northwind already loaded. One appears to be associated with SQL Server Mobile Edition (Samples folder) and another seems to be associated with Visual Studio 8\SDK\v2.0\Quickstart.

Can I use one of these existing Northwind databases (none have .mdf extention) for SQL Server 2005 or do I need to download yet another version?

You can either download a copy of the Northwind database here:

http://www.microsoft.com/downloads/details.aspx?FamilyID=06616212-0356-46a0-8da2-eebc53a68034&displaylang=en

It says it's for 2000, but it works fine for express. I use pubs a lot to this day, myself.

Buck Woody

|||

Here are links to the Northwind, Pubs, and AdventureWorks sample databases. It is worth having all three of them since many books, magazine articles, and web code is based upon them.

Databases -AdventureWorks
http://msdn2.microsoft.com/en-us/library/ms124659.aspx

Databases -Northwind and Pubs
http://www.microsoft.com/downloads/details.aspx?FamilyID=06616212-0356-46A0-8DA2-EEBC53A68034

Wednesday, March 21, 2012

DMX Query examples

Can you give an example on how exactly to write each of the following? (I am clearly not a programmer :))

TopCount ( <table expr>,<rank expr>,<n-items>) =

TopPercent ( <table expr>,<rank expr>,<percent>) =

PredictTimeSeries ( <table expr>,<n1>,<n2>) =

PredictAssociation ( <table expr>,<n>) =

Thanks,

Carrie

SELECT TopCount(PredictHistogram(MyAttribute),$Probability,3), // returns top 3 values by probability
TopPercent(PredictHistogram(MyAttribute),$Support,0.20) // returns top values that contain at least 20% of the total support
FROM MyModel
PREDICTION JOIN
...

SELECT PredictTimeSeries(MyNestedTableTimeSeriesColumn, 2, 5) // predicts steps 2-5 in the series
FROM MyTimeSeriesModel

SELECT PredictAssociation(MyNestedTable, 5) // returns top 5 associated items
FROM My Model
PREDICTION JOIN
...

|||

So I did.....

select TopCount(PredictHistogram(Returnwithplay),$Support,.20)

From [REC FT All Cube DT]

PREDICTION JOIN

And received the following ( I think the query completed with errors):

Executing the query ...

Parser: The end of the input was reached.

Execution complete

|||And I tried

select PredictTimeSeries([Slot Theo Win],2,5) FROM [Player Market]

and received the following error:

Executing the query ...

Error (Data mining): The specified DMX column was not found in the context at line 1, column 26.

Execution complete

My time series is set up as the following.......

Player Market:

Date Dim Predict

Day Key

Rated Slot Theo Predict Only

Rated Table Theo Predict Only

Player Market Dim Key

|||

PredictTimeSeries only works on models using the Microsoft_Time_Series algorithm. Also, it doesn't seem that you have a column called "Slot Theo Win" in your data set.

It seems you would need a model somewhat like

CREATE MINING MODEL [Player Market]
(
DateDim DATE KEY TIME,
PlayerMarketDim TEXT KEY,
RatedSlotTheo DOUBLE CONTINUOUS PREDICT_ONLY,
RatedSlotTheo DOUBLE CONTINUOUS PREDICT_ONLY
) USING Microsoft_Time_Series

sql

Monday, March 19, 2012

DMX from Java

My preferred programming language is Java (sorry Microsoft). I've searched for examples of running DMX queries into an Analysis Services database from Java but failed to locate any. I've seen suggestions that XMLA could be used but again, I can't locate any examples (in any language). For my current project I ran up the white flag and used C# instead but this wouldn't be an option in other cases. It would be possible to make the DMX calls from C# objects and call those from Java but that's pretty labourious to code.

Suggestions?

have you tried the XMLA Thin Client sample at http://www.sqlserverdatamining.com/DMCommunity/LiveSamples/124.aspx ?

|||I found that page but I didn't find any code sample to go with it.|||There's an old(er) code sample here http://www.sqlserverdatamining.com/DMCommunity/SQLServer2000/Links_LinkRedirector.aspx?id=96