Analytic Views: Einsatzgebiete im Data Warehouse Dani Schnider, Trivadis AG DOAG Konferenz, 21. November 2017 @dani_schnider DOAG2017
Unser Unternehmen. Trivadis ist führend bei der IT-Beratung, der Systemintegration, dem Solution Engineering und der Erbringung von IT-Services mit Fokussierung auf - und -Technologien in der Schweiz, Deutschland, Österreich und Dänemark. Trivadis erbringt ihre Leistungen aus den strategischen Geschäftsfeldern: B E T R I E B Trivadis Services übernimmt den korrespondierenden Betrieb Ihrer IT Systeme. 2 21.11.2017
Mit über 600 IT- und Fachexperten bei Ihnen vor Ort. KOPENHAGEN HAMBURG 14 Trivadis Niederlassungen mit über 600 Mitarbeitenden. Über 200 Service Level Agreements. Mehr als 4'000 Trainingsteilnehmer. DÜSSELDORF Forschungs- und Entwicklungsbudget: CHF 5.0 Mio. / EUR 4.0 Mio. FRANKFURT Finanziell unabhängig und nachhaltig profitabel. BASEL FREIBURG BRUGG ZÜRICH STUTTGART MÜNCHEN WIEN Erfahrung aus mehr als 1'900 Projekten pro Jahr bei über 800 Kunden. GENF 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)) ) DEFAULT MEASURE amount_sold 14 21.11.2017
Demo 1 a) Creating Attribute Dimensions b) Creating Hierarchies c) Creating Analytic Views 15 21.11.2017
Typical Use Cases 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, RPAD(' ', sh_products_hier.depth * 2) 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, sh_customers_hier.hier_order 19 21.11.2017
Query on Analytic View Result CALENDAR_HIER PRODUCTS_HIER AMOUNT_SOLD QUANTITY_SOLD ------------- ------------------------------------------------------ ----------- ------------- 1998 Electronics 1775688.87 9853 1998 Game Consoles 11.99 1 1998 Y Box 11.99 1 1998 Home Audio 1568900.57 2688 1998 8.3 Minitower Speaker 578374.62 1043 1998 Home Theatre Package with DVD-Audio/Video Play 990525.95 1645 1998 Y Box Accessories 73744.81 2684 1998 Extension Cable 1685.89 211 1998 Xtend Memory 72058.92 2473 1998 Y Box Games 133031.5 4480 1998 Adventures with Numbers 35771.66 2147 1998 Endurance Racing 97259.84 2333 1999 Electronics 2916369.92 24105 1999 Game Consoles 272901.18 884 1999 Y Box 272901.18 884... 2001 Fly Fishing 16726.41 2102 2001 Martial Arts Champions 53100.3 2506 2001 Smash up Boxing 100546.16 3121 66 rows selected. 20 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 21 21.11.2017
Analytic Views and BI Tools Example Tableau 22 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 23 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) 24 21.11.2017
Analytic Views and ETL Dim Dim Facts Analytic View Report Table Dim Dim 25 21.11.2017
Demo 2 a) Queries on Hierarchies b) Queries on Analytic Views c) A View behind the Scenes 26 21.11.2017
Conclusion 27 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 28 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 29 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 30 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 31 21.11.2017