Global Distribution Analysis Using Database Access Kit

download notebookDownload this example as a Mathematica notebook.

Northwind is the example database that ships with Microsoft Access. It contains the business data for a fictional gourmet food company with worldwide sales. In this example, we connect to the database using Database Access Kit, collect some summary information on the inventory, and take a look at the global distribution of customers.

Accessing the Database

Assuming that Northwind.mdb is already known to the ODBC control panel, you can just load the Database Access Kit application package into Mathematica, open the database, and assign a name to it.

[Graphics:Images/index_gr_1.gif]
[Graphics:Images/index_gr_2.gif]

DataSourceTables lists the available data tables in Northwind.

[Graphics:Images/index_gr_3.gif]
[Graphics:Images/index_gr_4.gif]
[Graphics:Images/index_gr_5.gif]
[Graphics:Images/index_gr_6.gif]
[Graphics:Images/index_gr_7.gif]
[Graphics:Images/index_gr_8.gif]
[Graphics:Images/index_gr_9.gif]
[Graphics:Images/index_gr_10.gif]
[Graphics:Images/index_gr_11.gif]

DataSourceDataTypes gives the types used in the database.

[Graphics:Images/index_gr_12.gif]
[Graphics:Images/index_gr_13.gif]


Getting Basic Information

By leaving out DataSourceEvaluate, you can verify how Mathematica assembles the SQL command from Mathematica functions.

[Graphics:Images/index_gr_14.gif]
[Graphics:Images/index_gr_15.gif]

The next command uses this SQLSelect function to read in the first product.

[Graphics:Images/index_gr_16.gif]
[Graphics:Images/index_gr_17.gif]

Let's see which products are less than eight dollars.

[Graphics:Images/index_gr_18.gif]
    ProductName UnitPrice
    Konbu 6.`
    Guaraná Fantástica 4.5`
    Geitost 2.5`
    Filo Mix 7.`
    Tourtière 7.45`
    Rhönbräu Klosterbier 7.75`

This result is identical to the one obtained by passing the SQL command directly.

[Graphics:Images/index_gr_19.gif]
    Konbu 6.`
    Guaraná Fantástica 4.5`
    Geitost 2.5`
    Filo Mix 7.`
    Tourtière 7.45`
    Rhönbräu Klosterbier 7.75`

The following calculates the value of the complete inventory at retail prices.

[Graphics:Images/index_gr_20.gif]
[Graphics:Images/index_gr_21.gif]

Load the package Graphics`Graphics`. Now you can create a bar chart of the number of items at hand.

[Graphics:Images/index_gr_22.gif]
[Graphics:Images/index_gr_23.gif]

[Graphics:Images/index_gr_24.gif]

World Logistics

The next command queries where the company has been shipping products.

[Graphics:Images/index_gr_25.gif]
[Graphics:Images/index_gr_26.gif]

Load the package WorldPlot` to display the result graphically.

 [Graphics:Images/index_gr_27.gif]

Color the countries that Northwind ships to in red, other countries in light gray.

   shadefunc[country_] :=
       If[MemberQ[shipcountries, country],
          RGBColor[1,0,0],GrayLevel[0.6]]
   WorldPlot[{World, shadefunc}];

[Graphics:Images/index_gr_28.gif]



 © 2008 Wolfram Research, Inc.  Terms of Use  Privacy Policy |
Sign up for our newsletter: