+ All Categories
Home > Documents > Relational DBMS Support for OLAP(OLAP-3)

Relational DBMS Support for OLAP(OLAP-3)

Date post: 06-Apr-2018
Category:
Upload: sunilpokhrael
View: 233 times
Download: 0 times
Share this document with a friend

of 47

Transcript
  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    1/47

    Page 1

    Relational DBMS support for

    OLAPBy

    Dr DVLN Somayajulu

    ProfessorDept of CSE

    National Institute of Technology

    WarangalE-Mail: [email protected]

    Relational DBMS support for

    OLAPBy

    Dr DVLN Somayajulu

    ProfessorDept of CSE

    National Institute of Technology

    WarangalE-Mail: somadvlns@

    gmail.com

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    2/47

    Page 2

    Lecture 39

    y Relational DBMS support for OLAP

    y Data Cube Demonstration using SQL

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    3/47

    OLAP Operators

    ySlicingyDicing

    yDrill downyRoll upyPivot

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    4/47

    OLAP OperatorsOperator Purpose Description

    Slice Focus attention on asubset of dimensions

    Replace a dimensionwith a single membervalue or with a

    summary of itsmeasure values

    Allows intuitive manipulation

    Imitates Projection operation

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    5/47

    OLAP Operators

    Imitates selection operation

    Operator Purpose Description

    Slice Focus attention on asubset of dimensions

    Replace a dimensionwith a single membervalue or with a

    summary of itsmeasure values

    Dice Focus attention on asubset of membervalues

    Replace a dimensionwith a subset ofmembers

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    6/47

    OLAP Operators

    More general level to detail levelof aggregation

    Operator Purpose Description

    Slice Focus attention on asubset of dimensions

    Replace a dimensionwith a single membervalue or with a

    summary of itsmeasure values

    Dice Focus attention on asubset of membervalues

    Replace a dimensionwith a subset ofmembers

    Drill-down Obtain more detail

    about a dimension

    Navigate from a more

    general level to amore specific level

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    7/47

    OLAP Operators

    Navigate from more specific level of aggregation

    to more general level of aggregation

    Operator Purpose Description

    Slice Focus attention on asubset of dimensions

    Replace a dimensionwith a single membervalue or with a summaryof its measure values

    Dice Focus attention on asubset of member values

    Replace a dimensionwith a subset ofmembers

    Drill-down Obtain more detail abouta dimension

    Navigate from a moregeneral level to a morespecific level

    Roll-up Summarize about adimension

    Navigate from a morespecific level to a moregeneral level

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    8/47

    OLAP OperatorsOperator Purpose Description

    Slice Focus attention on asubset of dimensions

    Replace a dimension with asingle member value orwith a summary of itsmeasure values

    Dice Focus attention on asubset of membervalues

    Replace a dimension with asubset of members

    Drill-down Obtain more detailabout a dimension

    Navigate from a moregeneral level to a more

    specific level

    Roll-up Summarize about adimension

    Navigate from a morespecific level to a moregeneral level

    Pivot Present data in a

    different order

    Rearrange the dimensions

    in a data cube

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    9/47

    Page 9

    Simple Aggregation

    Query: Add up amounts for day 1In SQL: SELECT sum(amt)

    FROM SALEWHERE date =1

    Sale ProdId StoreId Date amt

    p1 s1 1 12

    p2 s1 1 11

    P1 s3 1 50

    p2 s2 1 8P1 s1 2 44

    p1 s2 2 4

    81

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    10/47

    Page 10

    Simple Aggregation

    Query: Add up amounts for day 1In SQL: SELECT sum(amt)

    FROM SALEWHERE date =1

    Sale ProdId StoreId Date amt

    p1 s1 1 12

    p2 s1 1 11

    P1 s3 1 50

    p2 s2 1 8P1 s1 2 44

    p1 s2 2 4

    81

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    11/47

    Page 11

    Output ofSlice Operator

    Location Product

    Soda Diet Soda Lime Soda Orange Soda

    Hyderabad 80 110 60 25

    Kolkata 40 90 50 30

    Chennai 70 55 60 35

    Delhi 75 85 45 45

    Mumbai 65 45 85 60

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    12/47

    Page 12

    Dice Operator

    y Focus on a subset of membervalues

    y Replace dimension with a subset

    of valuesy Dice Operation often follows a

    slice operation

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    13/47

    Page 13

    Result ofDice Operator

    40 90 50 30

    Soda DietSoda

    OrangeSoda

    Limesoda

    LO

    CATION

    Kolkata

    PRODUCT

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    14/47

    Page 14

    Aggregates using SQL Gruoup by Clause

    y Add up amounts by dayy In SQL: SELECT date, sum(amt)

    FROM SALEGROUP BYdate

    Sale ProdId StoreId Date amt

    p1 s1 1 12

    p2 s1 1 11

    P1 s3 1 50

    p2 s2 1 8P1 s1 2 44

    p1 s2 2 4

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    15/47

    Page 15

    Output of Aggregated Query on Sale table

    Sale ProdId StoreId Date amt

    p1 s1 1 12

    p2 s1 1 11

    P1 s3 1 50

    p2 s2 1 8P1 s1 2 44

    p1 s2 2 4

    ans date sum

    1 81

    2 48

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    16/47

    Page 16

    Other OLAP Operations

    y Suitable for hierarchical dimensions Drill-down: add detail to a dimension Roll-up: remove detail from a dimension

    Recalculate measure values Pivot: rearrange dimensions

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    17/47

    Page 17

    Another Example

    y Add up amounts by day, producty In SQL: SELECT date, sum(amt)

    FROM SALEGROUP By date, prodId

    Sale ProdId StoreId Date amt

    p1 s1 1 12

    p2 s1 1 11

    P1 s3 1 50

    p2 s2 1 8P1 s1 2 44

    p1 s2 2 4

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    18/47

    Page 18

    Query Result

    Sale ProdId StoreId Date amt

    p1 s1 1 12

    p2 s1 1 11

    P1 s3 1 50

    p2 s2 1 8

    P1 s1 2 44

    p1 s2 2 4

    Sale ProdId StoreId Date amt

    p1 s1 1 12

    p2 s1 1 11

    P1 s3 1 50

    p2 s2 1 8

    P1 s1 2 44

    p1 s2 2 4

    Group1

    Group2

    Group3

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    19/47

    Page 19

    Query Result

    Sale ProdId StoreId Date amt

    p1 s1 1 12

    p2 s1 1 11

    P1 s3 1 50

    p2 s2 1 8

    P1 s1 2 44

    p1 s2 2 4

    Sale ProdId Date Amt

    P1 1 62

    P2 1 19

    P1 2 48

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    20/47

    Page 20

    Outline

    y OLAP Operatorsy Relational DBMS support for OLAPy Data Cube Demonstration in SQLy Categories of OLAP tools

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    21/47

    Page 21

    Support for OLAP in DBMS

    y Fundamental operation used in DW isaggregation

    y Features of SQL were enrichedsupport for performing OLAPoperations in most of commercialDBMSs. Oracle Database provides extensions for

    Group by Clause

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    22/47

    Page 22

    RelationalDBMSSupport for OLAP

    y Group By Grouping Set < column list> Short notation in SQL:99 for series of UNIONed

    Queries that are common in reports

    y Rollup extension

    y Cube extension

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    23/47

    Page 23

    Extensions of Group by Clause

    y Rollup extension: Compute aggregation such as sum, avg, max,

    min, count at increasing levels aggregationincluding highest value (grand total).

    y

    Cube extension: Computes all possible aggregations Heavy processing load is needed

    y Group By Grouping Set Short notation in SQL:99 for series of UNIONed

    queries that are common in reports

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    24/47

    Page 24

    Outline

    y OLAP Operators

    y Relational DBMS support for OLAP

    y Data Cube Demonstration in SQL

    y Categories of OLAP tools

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    25/47

    Page 25

    Cross Tab report With Sub Totals

    QUERY in SQL:

    SELECT channels.channel_desc, countries.country_iso_code,

    TO_CHAR(SUM(amount_sold), '9,999,999,999') SALES

    FROM sales, customers, times, channels, countries

    WHERE sales.time_id=times.time_id AND sales.cust_id=customers.cust_id AND

    sales.channel_id= channels.channel_id AND

    channels.channel_desc IN ('Direct Sales', 'Internet') AND

    times.calendar_month_desc='2000-09 AND

    customers.country_id=countries.country_id AND

    countries.country_iso_code IN (INDIA',USA')

    GROUP BY CUBE(channels.channel_desc, countries.country_iso_code);

    Country

    India USA Total

    Internet 9,597 124,224 133,821

    Direct Sales 61,202 638,201 699,403

    Total 70,799 762,425 833,224

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    26/47

    Page 26

    ROLLUP Extension to GROUP BY

    y Extension of Group by clausey Easy to use and Efficienty Syntax: SELECT GROUP BY ROLLUP

    (grouping_column_reference_list)

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    27/47

    Page 27

    ROLLUP Extension to GROUP BY

    y Extension of Group by clausey Easy to use and Efficienty Syntax: SELECT GROUP BY ROLLUP

    (grouping_column_reference_list)

    When to Use ROLLUP?y Use the ROLLUP extension in tasks involving

    subtotals.

    Suited to perform aggregation of data across hierarchical categories such as timeand horizon.

    y For data warehouse administrators using summary tables,ROLLUP can simplify and speed up the maintenance ofsummary tables

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    28/47

    CUBE Extension to Group By

    y CUBE takes a specified set of grouping columns

    and creates subtotals for all of their possible

    combinations.

    y CUBE generates all the subtotals that could be

    calculated for a data cube with the specifieddimensions.

    y CUBE (time, region, department), the result setwill include all the values that would be included inan equivalent ROLLUP statement plus additional

    combinations.

    y Ifn columns are specified for a CUBE, there will be2 to the n combinations of subtotals returned

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    29/47

    Page 29

    Advantages of CUBE Operator

    y Data required to generate cross tabreport can easily be computed withsingle SQL statement.

    y Very helpful in generating summarytables

    y Most suitable for queries suitable formultiple dimensions

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    30/47

    Page 30

    CUBE function

    Syntax:SELECT GROUP BY CUBE

    (grouping_column_reference_list)

    QUERY:

    SELECT channel_desc, calendar_month_desc, countries.country_iso_code,TO_CHAR(SUM(amount_sold), '9,999,999,999') SALES$FROM sales, customers, times, channels, countriesWHERE sales.time_id=times.time_id AND sales.cust_id=customers.cust_id AND

    sales.channel_id= channels.channel_id ANDcustomers.country_id = countries.country_id ANDchannels.channel_desc IN ('Direct Sales', 'Internet') AND

    times.calendar_month_desc IN ('2000-09', '2000-10') ANDcountries.country_iso_code IN ('GB', 'US')GROUP BY CUBE(channel_desc, calendar_month_desc, countries.country_iso_code ) ;

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    31/47

    Page 31

    Partial Cube Extension to

    GROUP BYy Partial cube:

    Syntax: GROUP BY expr1, cube(expr2, expr3);

    - Creates subtotals at 4 aggregate levels

    Example Query in SQL

    QUERY in SQL:

    SELECT channel_desc, calendar_month_desc, countries.country_iso_code,

    TO_CHAR(SUM(amount_sold), '9,999,999,999') SALES$

    FROM sales, customers, times, channels, countries

    WHERE sales.time_id = times.time_id

    AND sales.cust_id = customers.cust_id

    AND customers.country_id=countries.country_id

    AND sales.channel_id = channels.channel_id

    AND channels.channel_desc IN ('Direct Sales', 'Internet')

    AND times.calendar_month_desc IN ('2000-09', '2000-10')

    AND countries.country_iso_code IN ('GB', 'US')

    GROUP BY channel_desc, CUBE(calendar_month_desc, countries.country_iso_code);

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    32/47

    Page 32

    Discussion on CUBE

    y Question: Can we compute SubTotals without using Cube? Multiple Select statements combined with

    union operation returns the same result Require many select statements Use of many select statements leads to

    inefficient processing and need very lengthSQL statement

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    33/47

    Page 33

    Discussion on CUBE

    y Question: Can we compute Sub Totalswithout using Cube? Multiple Select statements combined with union operation

    returns the same result Require many select statements Use of many select statements leads to inefficient

    processing and need very length SQL statement

    y Question: What is the impact when we addone more dimension into it?

    More attributes/columns are included, we need sixteendifferent aggregation

    More dimensions are included, the greater savings withCube operator compared to Unioned approach

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    34/47

    Page 34

    GROUPING SETS Expression

    y To explicitly specify the set of groups that youwant to create within a GROUP BY clause using aGROUPING SETS expression.

    y This allows precise specification across multipledimensions without computing the whole CUBE

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    35/47

    Page 35

    Challenges with the use ofRollup and Cube

    y How can you programmatically determinewhich result set rows are subtotals,

    y How do you find the exact level of

    aggregation for a given subtotal?y Is there any way with ease to determine

    which rows are the subtotals?

    y What happens if query results contain bothstored NULL values and "NULL" valuescreated by a ROLLUP or CUBE?

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    36/47

    Page 36

    Lecture 40

    Categories of OLAP

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    37/47

    Page 37

    Categories of OLAP Tools

    y OLAP tools are categorized according tothe architecture of the underlyingdatabase.

    y Three main categories of OLAP toolsinclude Multi-dimensional OLAP (MOLAP

    or MD-OLAP) Relational OLAP (ROLAP), alsocalled multi-relational OLAP

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    38/47

    Page 38

    Multi-Dimensional OLAP (MOLAP)

    y Use array technology and efficientstorage techniques that minimize thedisk space requirements through

    sparse data management.

    y Provides excellent performance whendata is used as designed, and the focus

    is on data for a specific decision-support application.

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    39/47

    Page 39

    Multi-Dimensional OLAP (MOLAP)

    y Traditionally, require a tight couplingwith the application layer andpresentation layer.

    y Recent trends segregate the OLAP fromthe data structures through the use ofpublished application programminginterfaces (APIs).

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    40/47

    Page 40

    Typical Architecture for MOLAP

    Tools

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    41/47

    Page 41

    MOLAP Tools - Development Issues

    y Underlying data structures are limitedin their ability to support multiplesubject areas and to provide access todetailed data.

    y Navigation and analysis of data islimited because the data is designedaccording to previously determinedrequirements.

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    42/47

    Page 42

    MOLAP Tools - Development Issues

    y MOLAP products require a different setof skills and tools to build and maintainthe database, thus increasing the costand complexity of support.

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    43/47

    Page 43

    Relational OLAP (ROLAP)

    y Fastest growing style of OLAPtechnology.

    y

    Supports RDBMS products using ametadata layer - avoids need tocreate a static multi-dimensionaldata structure - facilitates thecreation of multiple multi-dimensional views of the two-dimensional relation.

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    44/47

    Page 44

    Relational OLAP (ROLAP)

    yTo improve performance, someproducts use SQL engines to

    support complexity of multi-dimensional analysis, whileothers recommend, or require,

    the use of highly de-normalizeddatabase designs such as thestar schema.

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    45/47

    Page 45

    Typical Architecture for ROLAP

    Tools

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    46/47

    Page 46

    ROLAPROLAP

    y A multi-dimensional user view onrelational data storage using Star orSnowflake Database Schemata.

    ProductDimension

    TimeDimension

    RegionDimension

    CustomerDimension

    ProductDimension

    YearDimension

    CountryDimension

    CustomerDimension

    Sales

    CustomerCharacteristics

    ProductKind

    Region

    Month

    Snowflake Schema

    Sales

    Star Schema

  • 8/2/2019 Relational DBMS Support for OLAP(OLAP-3)

    47/47

    Page 47

    OLAP TOOLS

    y

    Organize facts according to multiple dimensionsand they use powerful rules for combining

    those facts to form aggregate facts

    y Characteristics:

    To drill down into the data

    To swap the dimensions

    Allow changes in the appearance of the data

    y Provide flexibility

    y Vendors who sell these tools?

    Oracle with Oracle Express suite, Cognos withPowerPlay, Microstrategy with DSS agent, and many

    others.


Recommended