10 Copyright © 2005, Oracle. All rights reserved. Dimensions.

Slides:



Advertisements
Similar presentations
Using the SQL Access Advisor
Advertisements

Advanced Piloting Cruise Plot.
Advanced SQL Topics Edward Wu.
Feichter_DPG-SYKL03_Bild-01. Feichter_DPG-SYKL03_Bild-02.
Copyright © 2003 Pearson Education, Inc. Slide 1 Computer Systems Organization & Architecture Chapters 8-12 John D. Carpinelli.
Working with MS-ACCESS IS 240 – Database Management Lecture #2 – Assoc. Prof. M. E. Kabay, PhD, CISSP Norwich University
Chapter 1 The Study of Body Function Image PowerPoint
Author: Julia Richards and R. Scott Hawley
1 Copyright © 2013 Elsevier Inc. All rights reserved. Appendix 01.
1 Copyright © 2010, Elsevier Inc. All rights Reserved Fig 2.1 Chapter 2.
Chapter 1 Image Slides Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
UNITED NATIONS Shipment Details Report – January 2006.
19 Copyright © 2005, Oracle. All rights reserved. Distributing Modular Applications: Developing Web Services.
Refreshing Materialized Views
12 Copyright © 2005, Oracle. All rights reserved. Query Rewrite.
11 Copyright © 2005, Oracle. All rights reserved. Creating the Business Tier: Enterprise JavaBeans.
15 Copyright © 2005, Oracle. All rights reserved. Container-Managed Relationships (CMRs)
6 Copyright © 2005, Oracle. All rights reserved. Building Applications with Oracle JDeveloper 10g.
17 Copyright © 2005, Oracle. All rights reserved. Deploying Applications by Using Java Web Start.
Using the Set Operators
1 RA I Sub-Regional Training Seminar on CLIMAT&CLIMAT TEMP Reporting Casablanca, Morocco, 20 – 22 December 2005 Status of observing programmes in RA I.
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
FACTORING ax2 + bx + c Think “unfoil” Work down, Show all steps.
Addition Facts
Year 6 mental test 5 second questions
1 Term 2, 2004, Lecture 6, Views and SecurityMarian Ursu, Department of Computing, Goldsmiths College Views and Security 3.
Dr. Alexandra I. Cristea CS 252: Fundamentals of Relational Databases: SQL5.
ZMQS ZMQS
SQL: The Query Language Part 2
Information Systems Today: Managing in the Digital World
13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.
Yavapai College Self Service Banner Training. Agenda Definition of Key Concepts Log Into Finance Self Service Budget Query Overview Budget Query Procedures.
ABC Technology Project
CS 3630 Database Design and Implementation. Where Clause and Aggregate Functions -- List all rooms whose price is greater than the -- average room price.
11 Copyright © Oracle Corporation, All rights reserved. Managing Tables.
9 Copyright © 2004, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
3 Logic The Study of What’s True or False or Somewhere in Between.
Chapter 7 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey A. Hoffer, V. Ramesh, Heikki Topi.
Displaying Data from Multiple Tables
Creating Tables. 2 home back first prev next last What Will I Learn? List and provide an example of each of the number, character, and date data types.
VOORBLAD.
8 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Using Explicit Cursors.
15. Oktober Oktober Oktober 2012.
Note: A bolded number or letter refers to an entire lesson or appendix. A Adding Data Through a View ADD_MONTHS Function 03-22, 03-23, 03-46,
Factor P 16 8(8-5ab) 4(d² + 4) 3rs(2r – s) 15cd(1 + 2cd) 8(4a² + 3b²)
© 2012 National Heart Foundation of Australia. Slide 2.
Understanding Generalist Practice, 5e, Kirst-Ashman/Hull
Materialized Views.
Model and Relationships 6 M 1 M M M M M M M M M M M M M M M M
25 seconds left…...
Slippery Slope
Stephen C. Hayne 1 Database System Components The Database and the DBMS.
Januar MDMDFSSMDMDFSSS
Week 1.
We will resume in: 25 Minutes.
©Brooks/Cole, 2001 Chapter 12 Derived Types-- Enumerated, Structure and Union.
Intracellular Compartments and Transport
PSSA Preparation.
Essential Cell Biology
Murach’s OS/390 and z/OS JCLChapter 16, Slide 1 © 2002, Mike Murach & Associates, Inc.
Management Information Systems, 10/e
13 Copyright © Oracle Corporation, All rights reserved. Controlling User Access.
Oracle 11g: SQL Chapter 4 Constraints.
13 Copyright © Oracle Corporation, All rights reserved. Maintaining Data Integrity.
9 Copyright © 2006, Oracle. All rights reserved. Summary Management.
Presentation transcript:

10 Copyright © 2005, Oracle. All rights reserved. Dimensions

10-2 Copyright © 2005, Oracle. All rights reserved. Objectives After completing this lesson, you should be able to do the following: Create dimensions Validate dimension data View dimension definition information

10-3 Copyright © 2005, Oracle. All rights reserved. What Are Dimensions? Data dictionary structures that define hierarchies between pairs of column sets Used with materialized views for query rewrite Superset of referential constraints: –Normalized dimensions: Each child-side row joins with one and only one parent-side row. –Denormalized dimensions: Child-side columns uniquely determine the parent-side columns. Never enforced, but can be validated Enable additional query rewrites without the use of constraints

10-4 Copyright © 2005, Oracle. All rights reserved. Dimensions and Hierarchies MONTH_NAME Week Season ALL Level key Additional attribute Hierarchy CALENDAR_ROLLUP MONTH Level key attribute Year Quarter Sales date Month TIME_DIM dimension

10-5 Copyright © 2005, Oracle. All rights reserved. Full Notes Page

10-6 Copyright © 2005, Oracle. All rights reserved. Dimension Table: Example SQL> SELECT * FROM time; TIME_ID MONTH MONTH_NAM QUARTER YEAR JAN-02 M1_02 January02 Q1_ JAN-02 M1_02 January02 Q1_ JAN-02 M1_02 January02 Q1_ MAR-02 M2_02 March02 Q1_ DEC-02 M12_02 December02 Q4_ DEC-02 M12_02 December02 Q4_ Table used in examples in the lesson:

10-7 Copyright © 2005, Oracle. All rights reserved. Benefits of Dimensions SELECT year, sum(amount_sold) AS sumamt FROM time t, sales s WHERE t.time_id=s.time_id GROUP BY year; SELECT year, sum(sumamt) FROM sumsales mv, (SELECT DISTINCT month, year FROM times) v WHERE v.month = mv.month GROUP BY year; CREATE MATERIALIZED VIEW sumsales AS SELECT month, sum(amount_sold) AS sumamt FROM time t, sales s WHERE t.time_id = s.time_id GROUP BY month; Materialized view created User executes query Query rewritten

10-8 Copyright © 2005, Oracle. All rights reserved. Defining Dimensions and Hierarchies CREATE DIMENSION time_dim LEVEL sdate IS time.sdate LEVEL month IS time.month LEVEL qtr IS time.quarter LEVEL yr IS time.year HIERARCHY calendar_rollup ( sdate CHILD OF month CHILD OF qtr CHILD OF yr ) ATTRIBUTE month DETERMINES time.month_name; yr qtr month sdate

10-9 Copyright © 2005, Oracle. All rights reserved. Specifying the SKIP WHEN NULL Clause CREATE DIMENSION SALE_DATA_DIM LEVEL CUSTOMER IS SALE_DATA.CUST_ID LEVEL CITY IS SALE_DATA.CITY LEVEL STATE IS SALE_DATA.STATE SKIP WHEN NULL LEVEL COUNTRY IS SALE_DATA.COUNTRY HIERARCHY GEOG_ROLLUP (CUSTOMER CHILD OF CITY CHILD OF STATE CHILD OF COUNTRY) CUST_ID CITY STATE COUNTRY Washington, D.C. USA No state

10-10 Copyright © 2005, Oracle. All rights reserved. Full Notes Page

10-11 Copyright © 2005, Oracle. All rights reserved. Creating Dimensions Using Enterprise Manager create_dimension.gif

10-12 Copyright © 2005, Oracle. All rights reserved. Dimensions Based on Multiple Tables CREATE DIMENSION customers_dim LEVEL customer IS customers.cust_id LEVEL city IS customers.cust_city LEVEL state IS customers.cust_state_province LEVEL country IS countries.country_id LEVEL subregion IS countries.country_subregion LEVEL region IS countries.country_region HIERARCHY geo_rollup ( customer CHILD OF city CHILD OF state CHILD OF country CHILD OF subregion CHILD OF region JOIN KEY (customers.country_id) REFERENCES country) ATTRIBUTE customer DETERMINES (cust_first_name, cust_last_name) ATTRIBUTE country DETERMINES countries.country_name;

10-13 Copyright © 2005, Oracle. All rights reserved. Dimensions with Multiple Hierarchies CAL hierarchy WEEK hierarchy YEAR QUARTER MONTH DAY YEAR WEEK DAY

10-14 Copyright © 2005, Oracle. All rights reserved. Dimensions and Privileges CREATE DIMENSION CREATE ANY DIMENSION SELECT object privilege on each referenced object ALTER ANY DIMENSION DROP ANY DIMENSION

10-15 Copyright © 2005, Oracle. All rights reserved. Dimension Restrictions Two levels cannot have the same column set. Columns of a hierarchy level cannot be associated with more than one dimension. A hierarchy level cannot be a child of itself. All level key attributes for one level must belong to the same table. The JOIN clause is required if columns of different levels come from different tables. All additional attributes for one level key must belong to the same table. It is not possible to create dimensions based on views.

10-16 Copyright © 2005, Oracle. All rights reserved. Using VALIDATE_DIMENSION to Verify Relationships in a Dimension DBMS_DIMENSION.VALIDATE_DIMENSION ('SH.TIMES_DIM',TRUE,TRUE,'ver times_dim'); Check that levels are non-null Check only new rows in the tables Dimension owner and name User-supplied identifier

10-17 Copyright © 2005, Oracle. All rights reserved. Verifying Relationships in a Dimension DBMS_DIMENSION.VALIDATE_DIMENSION ('SH.CHANNELS_DIM', false, true, 'ver chan_dim'); SELECT * FROM sh.channels WHERE rowid IN (SELECT bad_rowid FROM dimension_exceptions WHERE statement_id = 'ver chan_dim'); CHANNEL_ID CHANNEL_DESC CHANNEL_CLASS S Direct Sales Direct S Security

10-18 Copyright © 2005, Oracle. All rights reserved. Viewing Dimensions Using Enterprise Manager view_dimension.gif

10-19 Copyright © 2005, Oracle. All rights reserved. Viewing Dimensions in the Data Dictionary DBA_DIMENSIONS DBA_DIM_LEVELS DBA_DIM_LEVEL_KEY DBA_DIM_ATTRIBUTES DBA_DIM_HIERARCHIES DBA_DIM_CHILD_OF DBA_DIM_JOIN_KEY

10-20 Copyright © 2005, Oracle. All rights reserved. Viewing the Definition of a Dimension SQL> SET SERVEROUTPUT ON FORMAT WRAPPED SQL> EXECUTE DBMS_DIMENSION.DESCRIBE_DIMENSION ('sh.channels_dim'); DIMENSION SH.CHANNELS_DIM LEVEL CHANNEL IS SH.CHANNELS.CHANNEL_ID LEVEL CHANNEL_CLASS IS SH.CHANNELS.CHANNEL_CLASS_ID LEVEL CHANNEL_TOTAL IS SH.CHANNELS.CHANNEL_TOTAL_ID HIERARCHY CHANNEL_ROLLUP ( CHANNEL CHILD OF CHANNEL_CLASS CHILD OF CHANNEL_TOTAL ) ATTRIBUTE CHANNEL LEVEL CHANNEL DETERMINES SH.CHANNELS.CHANNEL_DESC ATTRIBUTE CHANNEL_CLASS LEVEL CHANNEL_CLASS DETERMINES SH.CHANNELS.CHANNEL_CLASS ATTRIBUTE CHANNEL_TOTAL LEVEL CHANNEL_TOTAL DETERMINES SH.CHANNELS.CHANNEL_TOTAL

10-21 Copyright © 2005, Oracle. All rights reserved. Dimension Invalidation Invalidation is done automatically when related objects are altered. Verify a dimensions status through Enterprise Manager or the INVALID column of DBA_DIMENSIONS. Use the ALTER DIMENSION … COMPILE command to revalidate a dimension.

10-22 Copyright © 2005, Oracle. All rights reserved. Drop a dimension as follows: Does not invalidate materialized views that use relationships specified in the dimension Dropping Dimensions DROP DIMENSION channels_dim;

10-23 Copyright © 2005, Oracle. All rights reserved. Create the materialized view using the attribute LEVEL clause: Selectively drop a column: Selectively Dropping Dimension Components ALTER DIMENSION product_dim DROP ATTRIBUTE att LEVEL prod_id COLUMN prod_status; CREATE DIMENSION product_dim LEVEL prod_id IS (products.prod_id) ATTRIBUTE att LEVEL prod_id DETERMINES prod_name, prod_status;

10-24 Copyright © 2005, Oracle. All rights reserved. Constraints or Dimensions? For normalized dimensions, use: – PK/NOT NULL FK relationships as long as possible, or –Dimensions For denormalized dimensions, use dimensions. Joins between dimension and fact tables should be materialized by: – PK/NOT NULL FK relationships: NOVALIDATE RELY flags if validation is of concern, and/or –Dimensions, or –Joins-only materialized views defined with outer joins Always make sure dimensions are valid if used.

10-25 Copyright © 2005, Oracle. All rights reserved. Full Notes Page

10-26 Copyright © 2005, Oracle. All rights reserved. Summary In this lesson, you should have learned how to: Distinguish between dimensions and constraints Create dimensions Validate dimension data View dimension definitions

10-27 Copyright © 2005, Oracle. All rights reserved. Practice 10: Overview This practice covers the following topics: Creating dimensions on multiple tables Validating dimensions

10-28 Copyright © 2005, Oracle. All rights reserved.