Analytic Views: Use Cases in Data Warehouse Dani Schnider, Trivadis AG DOAG Conference, 21 November 2017 @dani_schnider DOAG2017
Our company. Trivadis is a market leader in IT consulting, system integration, solution engineering and the provision of IT services focusing on and technologies in Switzerland, Germany, Austria and Denmark. We offer our services in the following strategic business fields: O P E R A T I O N Trivadis Services takes over the interacting operation of your IT systems. 2 21.11.2017
With over 600 specialists and IT experts in your region. COPENHAGEN HAMBURG 14 Trivadis branches and more than 600 employees 200 Service Level Agreements Over 4,000 training participants DÜSSELDORF Research and development budget: CHF 5.0 million FRANKFURT Financially self-supporting and sustainably profitable BASEL FREIBURG STUTTGART BRUGG ZURICH MUNICH VIENNA Experience from more than 1,900 projects per year at over 800 customers GENEVA BERN LAUSANNE 3 21.11.2017
Dani Schnider Working for Trivadis in Glattbrugg/Zurich Senior Principal Consultant Data Warehouse Lead Architect Trainer of several Courses Co-Author of the books Data Warehousing mit Oracle Data Warehouse Blueprints Certified Data Vault Data Modeler @dani_schnider danischnider.wordpress.com 4 21.11.2017
What are Analytic Views? 5 21.11.2017
Overview Attribute Dimensions Hierarchies Dim Dim Analytic View Facts Dim Dim 6 21.11.2017
Dimensions and Hierarchies 7 21.11.2017
Attribute Dimension Data source: Dimension table (for star schemas) View on multiple dimension tables (for snowflake schemas) Member Attributes (columns of a dimension table or view) Caption and Description Hierarchy levels (incl. implicit level ALL ) Level Key Sort Order within hierarchy level Caption and Description Dimension type (STANDARD or TIME) 8 21.11.2017
Attribute Dimension Example CREATE OR REPLACE ATTRIBUTE DIMENSION sh_products_attr_dim USING sh.products ATTRIBUTES ( prod_id CLASSIFICATION caption VALUE 'Product' CLASSIFICATION description VALUE 'Product', prod_name CLASSIFICATION caption VALUE 'Product' CLASSIFICATION description VALUE 'Product', prod_subcategory CLASSIFICATION caption VALUE 'Subcategory' CLASSIFICATION description VALUE 'Subcategory', prod_category CLASSIFICATION caption VALUE 'Category' CLASSIFICATION description VALUE 'Category' ) LEVEL PRODUCT CLASSIFICATION caption VALUE 'Product' CLASSIFICATION description VALUE 'Product' KEY prod_id MEMBER NAME prod_name MEMBER CAPTION prod_name MEMBER DESCRIPTION prod_name ORDER BY prod_name DETERMINES (prod_subcategory)... 9 21.11.2017
Hierarchy Data source: Attribute Dimension Hierarchical Ordering of Levels Parent-child relationships between levels of an Attribute Dimension Aggregation Rows A row for each member of each level of the hierarchy Can be used in SELECT statements Multiple Hierarchies can be defined for one Attribute Dimension { } { } { } { } { } { } { } 10 21.11.2017
Hierarchy Example CREATE OR REPLACE HIERARCHY sh_products_hier CLASSIFICATION caption VALUE 'Products' CLASSIFICATION description VALUE 'Products' USING sh_products_attr_dim (product CHILD OF subcategory CHILD OF category) CREATE OR REPLACE HIERARCHY sh_times_calendar_hier CLASSIFICATION caption VALUE 'Calendar Year' CLASSIFICATION description VALUE 'Calendar Year' USING sh_times_attr_dim (day CHILD OF calendar_month CHILD OF calendar_quarter CHILD OF calendar_year) CREATE OR REPLACE HIERARCHY sh_times_fiscal_hier CLASSIFICATION caption VALUE 'Fiscal Year' CLASSIFICATION description VALUE 'Fiscal Year' USING sh_times_attr_dim (day CHILD OF fiscal_month CHILD OF fiscal_quarter CHILD OF fiscal_year) 11 21.11.2017
Analytic View Data source: Fact table of a star or snowflake schema References to Attribute Dimensions Key of fact table that references the dimension Hierarchies used in the dimension Base Measures Columns of the fact table Calculated Measures Expressions on base measures 12 21.11.2017
Analytic View Example (1) CREATE OR REPLACE ANALYTIC VIEW sh_sales_history_av USING sh.sales DIMENSION BY ( sh_times_attr_dim KEY time_id REFERENCES time_id HIERARCHIES (sh_times_calendar_hier DEFAULT, sh_times_fiscal_hier), sh_products_attr_dim KEY prod_id REFERENCES prod_id HIERARCHIES (sh_products_hier DEFAULT), sh_customers_attr_dim KEY cust_id REFERENCES cust_id HIERARCHIES (sh_customers_hier DEFAULT), sh_channels_attr_dim KEY channel_id REFERENCES channel_id HIERARCHIES (sh_channels_hier DEFAULT), sh_promotions_attr_dim KEY promo_id REFERENCES promo_id HIERARCHIES (sh_promotions_hier DEFAULT) ) MEASURES ( amount_sold FACT amount_sold, quantity_sold FACT quantity_sold ) 13 21.11.2017
Analytic View Example (2) CREATE OR REPLACE ANALYTIC VIEW sh_sales_history_av USING sh.sales DIMENSION BY (...) MEASURES ( -- Base Measures amount_sold FACT amount_sold, quantity_sold FACT quantity_sold, -- Calculated Measures amt_sold_shr_parent_prod AS (SHARE_OF(amount_sold HIERARCHY sh_products_hier PARENT)), sales_cal_ytd AS (SUM(amount_sold) OVER (HIERARCHY sh_times_calendar_hier BETWEEN UNBOUNDED PRECEDING AND CURRENT MEMBER WITHIN ANCESTOR AT LEVEL calendar_year)), sales_cal_year_ago AS (LAG(amount_sold) OVER (HIERARCHY sh_times_calendar_hier OFFSET 1 ACROSS ANCESTOR AT LEVEL calendar_year)) ) 14 21.11.2017
Demo 1 a) Creating Attribute Dimensions b) Creating Hierarchies c) Creating Analytic Views 15 21.11.2017
Queries on Analytic Views 16 21.11.2017
SQL Queries in Star Schema Dim Dim SQL Query Facts SQL Query Dim Dim 17 21.11.2017
SQL Queries in Star Schema Classical: Joins on Star Schema With Analytic View: SELECT d1,d2,d3, SUM(f1), SUM(f2) FROM fact f JOIN dim1 d1 ON ( ) JOIN dim2 d2 ON ( ) JOIN dim3 d3 ON ( ) WHERE (filter on dim1) AND (filter on dim2) GROUP BY d1,d2,d3 ORDER BY d1,d2,d3 SELECT h1,h2,h3, f1, f2 FROM analytic_view HIERARCHIES (h1,h2,h3) WHERE (filter on hierarchy1) AND (filter on hierarchy2) ORDER BY h1,h2,h3 18 21.11.2017
Query on Analytic View Example SELECT sh_times_calendar_hier.member_name AS calendar_hier, sh_products_hier.member_name AS products_hier, amount_sold, quantity_sold FROM sh_sales_history_av HIERARCHIES ( sh_times_calendar_hier, sh_products_hier) WHERE sh_times_calendar_hier.level_name = 'CALENDAR_YEAR' AND sh_products_hier.prod_category = 'Electronics' ORDER BY sh_times_calendar_hier.hier_order, sh_products_hier.hier_order 19 21.11.2017
Demo 2 a) Queries on Hierarchies b) Queries on Analytic Views c) A View behind the Scenes 21 21.11.2017
Typical Use Cases 22 21.11.2017
Analytic Views and BI Tools Example OBIEE Metadata Layer is part of BI Tool: OBIEE Business Model and Mapping SAP BusinessObjects Universe IBM Cognos Framework Manager 23 21.11.2017
Analytic Views and BI Tools Example Tableau 24 21.11.2017
Analytic Views and BI Tools For BI tools with metadata layer (e.g. OBIEE): No benefits with Analytic Views Import functionality would be useful For BI tools without metadata layer (e.g. Tableau, QlikView): Metadata definition in database Simplification of user queries ev. Views on top of Analytic Views required 25 21.11.2017
Analytic Views and ETL Analytic View can be Source for ETL Job Source should be Star Schema Physical (tables) or Virtual (views) Useful for Complex Calculations of Derived Measures Exports to Flat Structures (e.g. Standard Reports) 26 21.11.2017
Analytic Views and ETL Dim Dim Facts Analytic View Report Table Dim Dim 27 21.11.2017
Conclusion 28 21.11.2017
Conclusion: Analytic Views are A Powerful Extension of Oracle SQL Very flexible for Analytic Queries on Star Schemas Useful for Ad-hoc Queries in SQL Not (yet) supported by any BI Tools Not a Replacement of a Star Schema 29 21.11.2017
Oracle Documentation Oracle Database 12c Release 2, Data Warehousing Guide 24 Overview of Analytic Views 25 Attribute Dimension and Hierarchy Objects 26 Analytic View Objects Oracle Database 12c Release 2, SQL Language Reference CREATE ANALYTIC VIEW Calculated Measures Expressions Oracle Live SQL Creating an Analytic View for the Sales History (SH) Sample Schema Querying Analytic Views 30 21.11.2017
Additional Information Attribute Dimensions and Hierarchies in Oracle 12.2 Analytic Views: Powerful Oracle 12.2 Feature for Business Intelligence Analytic Views: A Performance Deep Dive Analysis danischnider.wordpress.com 31 21.11.2017
Trivadis @ DOAG 2017 #opencompany Stand: 3. Stock, direkt an der Rolltreppe Wir teilen unser Knowhow! Einfach vorbei kommen, Live-Präsentationen und Dokumentenarchiv T-Shirts, Gewinnspiel und mehr Wir freuen uns wenn Sie vorbei schauen 32 21.11.2017