0% found this document useful (0 votes)
12 views6 pages

DWM Exp 6

The document outlines the development of an OLAP application focusing on operations such as Slice and Dice, detailing the Java API packages and their functionalities. It includes code snippets for establishing a JDBC connection, creating data providers, and executing OLAP operations to create cubes and display results. The conclusion emphasizes the study of OLAP operations, with an assessment scheme provided for evaluating the process and product related to the experiment.

Uploaded by

giteanuja09
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views6 pages

DWM Exp 6

The document outlines the development of an OLAP application focusing on operations such as Slice and Dice, detailing the Java API packages and their functionalities. It includes code snippets for establishing a JDBC connection, creating data providers, and executing OLAP operations to create cubes and display results. The conclusion emphasizes the study of OLAP operations, with an assessment scheme provided for evaluating the process and product related to the experiment.

Uploaded by

giteanuja09
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Experiment 6

Title: Develop an application for OLAP and its operations: Slice & Dice

CO: Design the Data Warehouse and perform various operations.

Theory:

Packages of the OLAP Java API under oracle.olapi


Package Description
data.cursor Contains classes that represent cursor managers and cursors
that retrieve the data specified by a Source object.

data.source Contains classes that represent data sources and cursor


specifications. You use Source objects to create queries of the
data store. With the Template class you can incrementally build
a Source object that represents a query that you can dynamically
modify.

metadata Contains classes that represent metadata objects, classes that


metadata.deployment map the metadata objects to relational data sources, and classes
metadata.mapping that deploy the metadata objects in an analytic workspace or in
metadata.mdm relational database structures.

resource Contains classes that support the internationalization of


messages for Exception classes.

session Contains a class that represents a session in a connection to an


Oracle database.

syntax Contains classes that represent the items and commands that
specify how Oracle OLAP builds analytic workspace objects and
classes that implement a syntax for creating SQL-like
expressions. You use Expression objects in mapping metadata
objects to relational data sources such as columns in a table or a
view. You also use Expression objects to specify calculations
and analytical operations for some metadata objects.

transaction Contains classes that represent transactions with Oracle OLAP


in an Oracle Database instance. You use Transaction objects to
commit changes to the database.

The OLAP Java API also has packages organized under


the oracle.express package. These packages date from the earliest versions of the
API. The classes that remain in these packages are mostly Exception classes for
exceptions that occur during interactions between Oracle OLAP and a client
application.
Getting a JDBC Oracle Connection to DATASET:
oracle.jdbc.OracleConnection conn = null;
try
{
OracleDataSource ods = new OracleDataSource();
ods.setURL(props.getProperty("url"));
ods.setUser(props.getProperty("user"));
ods.setPassword(props.getProperty("password"));
conn = (oracle.jdbc.OracleConnection) ods.getConnection();
}
catch(SQLException e)
{
System.out.println("Connection attempt failed. " + e);
}

Creating a Data Provider:


DataProvider dp = new DataProvider();
try
{
UserSession session = dp.createSession(conn);
}
catch(SQLException e)
{
System.out.println("Could not create a UserSession. " + e);
}

Closing the Connection and the Data Provider


dp.close(); // dp is the DataProvider

Closing the Connection


try
{
conn.close(); // conn is the OracleConnection
}
catch(SQLException e)
{
System.out.println("Cannot close the connection. " + e);
}
Creating a Cube using Data Set:
// Create Parameter objects with values from the hierarchies
// of the CUSTOMER_AWJ and PRODUCT_AWJ dimensions.
StringParameter custParam =
new StringParameter(dp, "SHIPMENTS::REGION::EMEA");
StringParameter prodParam =
new StringParameter(dp, "PRODUCT_PRIMARY::FAMILY::LTPC");

// Create parameterized Source objects using the Parameter objects.


Source custParamSrc = custParam.createSource();
Source prodParamSrc = prodParam.createSource();

// Select single values from the hierarchies, using the Parameter


// objects as the comparisons in the join operations.
Source paramCustSel = custHier.join(custHier.value(), custParamSrc);
Source paramProdSel = prodHier.join(prodHier.value(), prodParamSrc);

// Select members from the other dimensions of the measure.


Source timeSel =
timeHier.selectValues(new String[] {"CALENDAR_YEAR::YEAR::CY1999"
"CALENDAR_YEAR::YEAR::CY2000",
"CALENDAR_YEAR::YEAR::CY2001"});
Source chanSel =
chanHier.selectValues(new String[] {"CHANNEL_PRIMARY::CHANNEL::DIR",
"CHANNEL_PRIMARY::CHANNEL::CAT ",
"CHANNEL_PRIMARY::CHANNEL::INT"});

// Join the hierarchy selections to the short description attributes


// for the dimensions.
Source columnEdge = chanSel.join(chanShortDescr);
Source rowEdge = timeSel.join(timeShortDescr);
Source page1 = paramProdSel.join(prodShortDescr);
Source page2 = paramCustSel.join(custShortDescr);

// Join the dimension selections to the measure.


Source cube = units.join(columnEdge)
.join(rowEdge)
.join(page2)
.join(page1);

// The following method commits the current Transaction.


getContext().commit();

// Create a Cursor for the query.


CursorManager cursorMngr = dp.createCursorManager(cube);
CompoundCursor cubeCursor = (CompoundCursor) cursorMngr.createCursor();

// Display the values of the Cursor as a crosstab.


getContext().displayCursorAsCrosstab(cubeCursor);
// Change the customer parameter value.
custParam.setValue("SHIPMENTS::REGION::AMER");

// Reset the Cursor position to 1 and display the values again.


cubeCursor.setPosition(1);
println();
getContext().displayCursorAsCrosstab(cubeCursor);

// Pivot the column and row edges.


columnEdge = timeSel.join(timeShortDescr);
rowEdge = chanSel.join(chanShortDescr);

// Join the dimension selections to the measure.


cube = units.join(columnEdge)
.join(rowEdge))
.join(page2)
.join(page1);

// Commit the current Transaction.


getContext().commit();

// Create another Cursor.


cursorMngr = dp.createCursorManager(cube);
cubeCursor = (CompoundCursor) cursorMngr.createCursor();
getContext().displayCursorAsCrosstab(cubeCursor);

// Change the product parameter value.


prodParam.setValue("PRODUCT_PRIMARY::FAMILY::DTPC");

// Reset the Cursor position to 1


cubeCursor.setPosition(1);
println();
getContext().displayCursorAsCrosstab(cubeCursor);
Code: Slice Dice Operations:
Source sortedProduct =
prodHier.recursiveJoin(units,
units.getDataType(),
prodParentAttr,
Source.COMPARISON_RULE_ASCENDING,
true, // Parents first
true); // Restrict parents to base

Source sortedProductShortDescr = prodShortDescr.join(sortedProduct);


Source result = units.join(sortedProductShortDescr)
.joinHidden(custSel)
.joinHidden(chanSel)
.joinHidden(timeSel);

A Cursor for the result Source has the following values, displayed in a table with
column headings and formatting added. The left column has the name of the level in
the PRODUCT_PRIMARY hierarchy. The next column to the right has the product
identification value, and the next column has the short value description of the
product. The rightmost column has the number of units of the product sold to all
customers in the year 2001 through the direct sales channel.
The table contains only the first nine and the last eleven values of the Cursor, plus
the Software/Other class value. The product values are listed hierarchically and in
ascending order by units sold. The Hardware class appears before the
Software/Other class because the Software/Other class has a greater number of
units sold. In the Hardware class, the Portable PCs family sold the fewest units, so it
appears first. In the Software/Other class, the Accessories family has the greatest
number of units sold, so it appears last.

Product Level ID Description Units Sold


------------- ------------ ----------------------------- ----------
TOTAL_PRODUCT TOTAL Total Product 43,785
CLASS HRD Hardware 16,543
FAMILY LTPC Portable PCs 1,192
ITEM ENVY ABM Envoy Ambassador 330
ITEM ENVY EXE Envoy Executive 385
ITEM ENVY STD Envoy Standard 477
FAMILY MON Monitors 1,193
ITEM 19 SVGA Monitor- 19" Super VGA 207
ITEM 17 SVGA Monitor- 17"Super VGA 986
TEM KBRD REST Keyboard Wrist Rest 2,231
ITEM LT CASE Laptop carrying case 3,704
ITEM DLX MOUSE Deluxe Mouse 3,884
ITEM MOUSE PAD Mouse Pad 4,456
Code: Getting the Share of Units Sold
Source totalProds =
prodHier.selectValue("PRODUCT_PRIMARY::TOTAL_PRODUCT::TOTAL");
NumberSource totalUnits = (NumberSource) units.joinHidden(totalProds);
Source productShare = units.div(totalUnits).times(100);
Source result =
productShare.join(prodFamilies)
.join(timeHier, "CALENDAR_YEAR::YEAR::CY2001")
.join(chanHier, "CHANNEL_PRIMARY::CHANNEL::DIR")
.join(custHier, "SHIPMENTS::TOTAL_CUSTOMER::TOTAL");
Source sortedResult = result.sortAscending();
A Cursor for the sortedResult Source has the following values, displayed in a table
with column headings and formatting added. The left column has the product family
value and the right column has the share of the total number of units sold for the
product family to all customers through the direct sales channel in the year 2001.

Output:
Product Family Member Share of Total Units Sold
----------------------------- -------------------------
PRODUCT_PRIMARY::FAMILY::LTPC 2.72%
PRODUCT_PRIMARY::FAMILY::MON 2.73%
PRODUCT_PRIMARY::FAMILY::MEM 3.57%
PRODUCT_PRIMARY::FAMILY::DTPC 5.13%
PRODUCT_PRIMARY::FAMILY::DOC 6.4%
PRODUCT_PRIMARY::FAMILY::DISK 11.71%
PRODUCT_PRIMARY::FAMILY::MOD 11.92%
PRODUCT_PRIMARY::FAMILY::OS 12.54%
PRODUCT_PRIMARY::FAMILY::ACC 43.28%

Conclusion: We have studied the OLAP operations like slice and dice.

Assessment Scheme:

Process Related Product Related Total


Sign of Teacher
(15 Marks) (10 Marks) (25 Marks)

You might also like