Download presentation
Presentation is loading. Please wait.
Published byUrsula Hicks Modified over 9 years ago
1
© 2014 Zvi M. Kedem 1 Unit 11 Online Analytical Processing (OLAP) Basic Concepts
2
© 2014 Zvi M. Kedem 2 OLAP in Context
3
© 2014 Zvi M. Kedem 3 OLAP vs. OLTP uWe have focused until now on OLTP: Online Transaction Processing uThis dealt with storing data both logically and physically and managing transactions querying and modifying the data uWe will now focus providing support for analytical queries, essentially statistical and summary information for decision-makers, that is on OLAP: Online Analytical Processing uThis may be accomplished by preprocessing, for efficiency purposes, and producing special types of views, which are also not necessarily up to date Not up to date may not be a problem in OLAP uData for OLAP (and more generally for data mining) is frequently stored in a Data Warehouse
4
© 2014 Zvi M. Kedem 4 Example uOur company has several stores and sells several products uThe stores are in different locations uThe locations, identified by (city,state) pairs are grouped into several regions uWe divide the time of sale into four quarters uThe quarters are grouped into two half-years
5
© 2014 Zvi M. Kedem 5 Our Company StoreStore#CityStateRegion AlphaNew YorkNYNE BetaAlbanyNYNE QuarterQuarter#Half_Year 1First 2 3Second 4 ProductProduct#WeightPrice Book4100 Glass15200
6
© 2014 Zvi M. Kedem 6 Our Sales SaleStore#Product#Quarter#$ AlphaBook170,000 AlphaGlass190,000 BetaBook190,000 BetaGlass180,000 AlphaBook290,000 AlphaGlass290,000 BetaBook260,000 BetaGlass250,000 AlphaBook360,000 AlphaGlass380,000 BetaBook350,000 BetaGlass390,000 AlphaBook450,000 AlphaGlass450,000 BetaBook470,000 BetaGlass470,000
7
© 2014 Zvi M. Kedem 7 Star Schema uWe want to support queries useful for statistical analysis by computing various sums, averages, etc. uThe structure we have is a star schema uIn the middle we have our facts table
8
© 2014 Zvi M. Kedem 8 Snowflake Schema: Normalized Star Schema uOne could also normalize, as table Store is not normalized, since State Region uThen, one could get, which we will not consider further, a snowflake schema
9
© 2014 Zvi M. Kedem 9 Cube uWe could think of each row of fact table as occupying a voxel (volume element) in a cube uCube, in general, can have any number of dimensions; in our example there are three uThis cube can then be sliced and diced
10
© 2014 Zvi M. Kedem 10 Slice uSELECT Store#, Product#, SUM($) FROM Sale GROUP BY Store#, Product# uWe can do all kinds of such slices
11
© 2014 Zvi M. Kedem 11 Dimension Hierarchies uDimensions could have hierarchies (or more generally even lattices) uWe have two very simple hierarchies One temporal: quarters are in half years One geographical: cities are in states are in regions
12
© 2014 Zvi M. Kedem 12 Using Hierarchies uSELECT Sale.Product#, Quarter.Half_Year, SUM($) FROM Sale, Quarter WHERE Sale.Quarter# = Quarter.Quarter# GROUP BY Half_Year; uWill produce summaries by half years, not quarters
13
© 2014 Zvi M. Kedem 13 New Operator: CUBE uSELECT Store#, Product#, SUM($) FROM Sale GROUP BY CUBE (Store#,Product#); uWill produce all possible aggregations based on subsets of {Store#,Product#}, best explained by looking at what will come out Store#Product#$ AlphaBook270,000 AlphaGlass310,000 BetaBook270,000 BetaGlass290,000 AlphaNULL580,000 BetaNULL560,000 NULLBook540,000 NULLGlass600,000 NULL 1,140,000
14
© 2014 Zvi M. Kedem 14 New Operator: ROLLUP uROLLUP produces only some of the aggregate operators produced by CUBE, best explained by example uSELECT Store#, Product#, SUM($) FROM Sale GROUP BY ROLLUP (Store#,Product#); Store#Product#$ AlphaBook270,000 AlphaGlass310,000 BetaBook270,000 BetaGlass290,000 AlphaNULL580,000 BetaNULL560,000 NULL 1,140,000
15
© 2014 Zvi M. Kedem 15 ROLAP And MOLAP uROLAP: Relational OLAP uThat is what we have been doing: OLAP information was stored as a set of star (or more generally snowflakes) schemas uMOLAP: Multidimensional OLAP uInformation not stored as a relational database, but essentially as a cube
16
© 2014 Zvi M. Kedem 16 Oracle uOracle supports OLAP uFollowing is the SQL code
17
© 2014 Zvi M. Kedem 17 Oracle: Defining the Database create table store( sid char(20) primary key, city char(20), state char(20), region char(20) ); create table product( pid char(20) primary key, weight number, price number ); create table quarter( qid number primary key, half_year char(10) );
18
© 2014 Zvi M. Kedem 18 Oracle: Defining the Database create table sale( sid char(20), pid char(20), qid number, profit number, primary key(qid, pid, sid), foreign key(qid) references quarter(qid), foreign key(pid) references product(pid), foreign key(sid) references store(sid) );
19
© 2014 Zvi M. Kedem 19 Oracle: OLAP Query select sid, pid, sum(profit) from sale group by rollup(sid, pid); select sid, pid, sum(profit) from sale group by cube(sid, pid);
20
© 2014 Zvi M. Kedem 20 Key Ideas uOLAP vs. OLTP uStar schema uSnowflake schema uCube uSlicing and dicing uDimension hierarchies uROLAP uMOLAP
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.