Professional Documents
Culture Documents
Roll no : 23
PRN : 1814110641
ADBMS: Assignment – 06
Study and demonstrating of OLAP operations in SQL:
OLAP (online analytical processing) is a computing method that enables users to easily and
selectively extract and query data in order to analyze it from different points of view. OLAP business
intelligence queries often aid in trends analysis, financial reporting, sales forecasting, budgeting and
other planning purposes.
For example, a user can request that data be analyzed to display a spreadsheet showing all of a
company's beach ball products sold in Florida in the month of July, compare revenue figures with
those for the same products in September and then see a comparison of other product sales in
Florida in the same time period.
Brief history
The term OLAP firstly appeared in 1993. It was invented by ‘the father of the relational database’
Edgar F. Codd in his article Providing OLAP (On-Line Analytical Processing) to User-Analysts: An IT
Mandate. But the idea of processing multidimensional data dates back to 1962, when Ken Iverson
published his work A Programming Language, APL. This language was used in many business
applications that are functionally similar to modern OLAP-systems.
Features
The key OLAP features usually are:
Data views in multidimensional manner;
Complex calculations support;
Time intelligence;
Easy-to-use interface.
So, there are about nine different OLAP types, but we can distinguish three main:
1. ROLAP
Relational OLAP are the systems that have direct access to existing relational databases or use data
uploaded to their own local tables. ROLAP works in the following way: The system sends the query
to a relational database – the required data turns back The key benefit of this system is that the
questions’ number is not limited as there are no boundaries generated by the cube content. It is also
possible to drill down in detail to the database lowest level. Also, relational DBMS provide security
and administration.
2. MOLAP
Multidimensional OLAP in comparison with previous type stores data in multidimensional database.
It means I is possible to manipulate data as a multidimensional array, so that the speed of calculating
aggregate values is the same for any of the measurements. Multidimensional OLAP architecture
includes:
MOLAP server
Database server
Front-end tool
MOLAP involves creation of an explicit, physically stored multidimensional cube (or several cubes)
with the execution of analytical queries only on them, without reference to the relational database.
In this case, the highest productivity is achieved.
3. HOLAP
Hybrid OLAP, as it is clear from the name, combines the features of both ROLAP and MOLAP.
Wherein, HOLAP uses advantages of both and minimize disadvantages. Talking about Hybrid OLAP
architecture, the cube structure and pre-computed aggregates are stored in a multidimensional
database. It promotes rapid extraction of aggregates from MOLAP structures. The lower-level values
of the hierarchy in HOLAP remain in the relational data mart, which serves as the data source for the
cube. Some other OLAP types are:
WOLAP (Web OLAP) – a three-tier architecture includes client, middleware and database
server. The access through web browser.
SOLAP (Spatial OLAP) – combines possibilities of standard OLAP and Geographic Information
Systems in one UI.
DOLAP (Desktop OLAP) – provides opportunity to work with dataset on user’s desktop. To do
that it is just necessary to download data from the source.
Mobile OLAP - related to wireless networks or mobile devices. Mobile OLAP implementation
allows you to work with OLAP data and applications remotely via mobile devices.
Uses of OLAP
OLAP can be used for data mining or the discovery of previously undiscerned relationships between
data items. An OLAP database does not need to be as large as a data warehouse, since not all
transactional data is needed for trend analysis. Using Open Database Connectivity (ODBC), data can
be imported from existing relational databases to create a multidimensional database for OLAP.
OLAP products include IBM Cognos, Oracle OLAP and Oracle Essbase. OLAP features are also
included in tools such as Microsoft Excel and Microsoft SQL Server's Analysis Services). OLAP
products are typically designed for multiple-user environments, with the cost of the software based
on the number of users.
OLAP operations:
There are five basic analytical operations that can be performed on an OLAP cube:
Drill down: In drill-down operation, the less detailed data is converted into highly detailed data. It
can be done by:
In the cube given in overview section, the drill down operation is performed by moving down in the
concept hierarchy of Time dimension (Quarter -> Month).
Roll up: It is just opposite of the drill-down operation. It performs aggregation on the OLAP cube. It
can be done by:
In the cube given in the overview section, the roll-up operation is performed by climbing up in the
concept hierarchy of Location dimension (City -> Country).
Dice: It selects a sub-cube from the OLAP cube by selecting two or more dimensions. In the cube
given in the overview section, a sub-cube is selected by selecting following dimensions with criteria:
Pivot: It is also known as rotation operation as it rotates the current view to get a new view of the
representation. In the sub-cube obtained after the slice operation, performing pivot operation gives
a new view of it.
SELECT CASE WHEN grouping(QUARTER) = 1 THEN 'All' ELSE QUARTER END AS QUARTER, CASE WHEN
grouping(REGION) = 1 THEN 'All' ELSE REGION END AS REGION, SUM(SALES)
FROM SALESTABLE
GROUP BY CUBE (QUARTER, REGION)
The grouping() function returns 1 in case a NULL value is generated during the aggregation
and 0 otherwise. This distinguishes the generated NULLs and the possible real NULLs
stemming from the data. We will not add this to the subsequent OLAP queries so as to not
unnecessarily complicate them.
2) The ROLLUP operator computes the union on every prefix of the list of specified attribute
types, from the most detailed up to the grand total. It is especially useful to generate
reports containing both subtotals and totals. The key difference between the ROLLUP and
CUBE operator is that the former generates a result set showing the aggregates for a
hierarchy of values of the specified attribute types, whereas the latter generates a result set
showing the aggregates for all combinations of values of the selected attribute types.
Hence, the order in which the attribute types are mentioned is important for the ROLLUP
but not for the CUBE operator.