Академический Документы
Профессиональный Документы
Культура Документы
Analytic Functions
UI and Formatting
Calculations (build-in functions, formulas)
What-If analysis
Performance
Why Better?
SQL Model
Concepts
prod time
vcr
dvd
Define Relation as
Array
2001
2001
9
0
Relation
time
Array
1999
2000
2001
dvd
tv
pc
vcr
prod
prod time
vcr
dvd
2001
2001
9
0
Relation
time
Array
1999
2000
2001
dvd
tv
pc
vcr
prod
prod time
vcr
dvd
Evaluate Formulas
1st
2001
2001
9
0
Relation
Array
1999
2000
2001
dvd
tv
pc
vcr
prod time
vcr
dvd
Evaluate Formulas
2nd
2001
2001
9
0
Relation
1999
2000
2001
2002
11
vcr
dvd
tv
pc
RULES UPSERT
(
s[ANY, 2000] = s[CV(prod), CV(time) - 1] * 2,
s[vcr, 2002] = s[vcr, 2001] + s[vcr, 2000],
s[dvd, 2002] = AVG(s) [CV(prod), time<2001]
)
prod time
vcr
dvd
Evaluate Formulas
3rd
2001
2001
9
0
Relation
1999
2000
2001
2002
11 3
vcr
dvd
tv
pc
RULES UPSERT
(
s[ANY, 2000] = s[CV(prod), CV(time) - 1] * 2,
s[vcr, 2002] = s[vcr, 2001] + s[vcr, 2000],
s[dvd, 2002] = AVG(s) [CV(prod), time<2001]
)
prod time
vcr
dvd
Return as Relation
2001
2001
9
0
Relation
1999
2000
2001
2002
11 3
vcr
dvd
tv
pc
Self-join.
join + UNION
join + UNION
RULES UPSERT
(
s[ANY, 2000] = s[CV(prod), CV(time) - 1] * 2,
s[vcr, 2002] = s[vcr, 2001] + s[vcr, 2000],
s[dvd, 2002] = AVG(s) [CV(prod), time<2001]
)
Relation again
vcr
dvd
2001
2001
9
0
vcr
dvd
2002
2002
11
3
Partitioning
Dims of array
Model options
Formulas
Formula Options
single ref
multi ref on right
2002
2003
2004
2005
350.00
400.00
450.00
500.00
ORDER BY t
300.00
2001
2002
2003
2004
2005
300.00
350.00
400.00
450.00
500.00
ORDER BY t
0
300.00
350.00
2001
2002
2003
2004
2005
300.00
350.00
400.00
450.00
500.00
ORDER BY t
0
300.00
350.00
400.00
450.00
Model Options
Fundamentals
global options
MODEL
[ UNIQUE DIMENSIONS | UNIQUE SINGLE REFERENCE ]
[ IGNORE NAV | KEEP NAV ]
PARTITION BY (r) DIMENSION BY (p, t) MEASURES (s)
RULES [ UPDATE | UPSERT ]
rule
[ AUTOMATIC ORDER | SEQUENTIAL ORDER ]
(
s[ANY, 2002] = 1.2 * s[CV(product), 2002],
s[dvd, 2003] = s[dvd, 2002] + s[dvd, 2001],
s[vcr, 2003] = AVG(s) [vcr, t BETWEEN 1995 AND 2000],
s[video, 2003] = s[dvd, 2003], s[vcr, 2003]
)
options
tv
vcr
vcr
2002
2001
2002
500.00
200.00
400.00
2001
West
West
West
West
West
West
dvd
tv
dvd
tv
vcr
vcr
2001
2002
2003
2003
2001
2002
300.00
500.00
500.00
200.00
400.00
tv
vcr
vcr
2002
2001
2002
500.00
200.00
400.00
assume 0
West
West
West
West
West
West
dvd
tv
dvd
tv
vcr
vcr
2001
2002
2003
2003
2001
2002
300.00
500.00
300.00
500.00
200.00
400.00
tv
vcr
vcr
2002
2001
2002
500.00
200.00
400.00
2001
West
West
West
West
West
West
dvd
tv
dvd
tv
vcr
vcr
2001
2002
2003
2003
2001
2002
300.00
500.00
500.00
200.00
400.00
assume 0
West
West
West
West
West
West
dvd
tv
dvd
tv
vcr
vcr
2001
2002
2003
2003
2001
2002
300.00
500.00
300.00
500.00
200.00
400.00
Automatic Formula
Ordering
MODEL PARTITION BY (r) DIMENSION BY (p, t) MEASURES (s)
RULES UPDATE AUTOMATIC ORDER
(
F1: s[vcr, 2003] = AVG(s) [vcr, t BETWEEN 1995 AND 2002],
F2: s[dvd, 2003] = s[dvd, 2002] + s[dvd, 2001],
F3: s[ANY, 2002] = s[CV(p), 2001] + s[CV(p), 1999]
)
Automatic Formula
Ordering
MODEL PARTITION BY (r) DIMENSION BY (p, t) MEASURES (s)
RULES UPDATE AUTOMATIC ORDER
(
F1: s[vcr, 2003] = AVG(s) [vcr, t BETWEEN 1995 AND 2002],
F2: s[dvd, 2003] = s[dvd, 2002] + s[dvd, 2001],
F3: s[ANY, 2002] = s[CV(p), 2001] + s[CV(p), 1999]
)
F1 depends on F3 and F2 depends on F3, thus F3 automatically first:
Automatic Formula
Ordering
MODEL PARTITION BY (r) DIMENSION BY (p, t) MEASURES (s)
RULES UPDATE AUTOMATIC ORDER
(
F1: s[vcr, 2003] = AVG(s) [vcr, t BETWEEN 1995 AND 2002],
F2: s[dvd, 2003] = s[dvd, 2002] + s[dvd, 2001],
F3: s[ANY, 2002] = s[CV(p), 2001] + s[CV(p), 1999]
)
F1 depends on F3 and F2 depends on F3, thus F3 automatically first:
RULES UPDATE AUTOMATIC ORDER
(
F3: s[ANY, 2002] = s[CV(p), 2001] + s[CV(p), 1999]
F2: s[dvd, 2003] = s[dvd, 2002] + s[dvd, 2001],
F1: s[vcr, 2003] = AVG(s) [vcr, t BETWEEN 1995 AND 2000]
)
dvd
vcr
dvd
2002
2002
2001
150
100
200
dvd
vcr
dvd
2002
2002
2001
150
100
200
Region
East
East
East
Product Time
dvd
2001
dvd
2002
vcr
2002
West
dvd
2001
Old s
100
150
100
200
New s
100
100
120
200
updated
dvd
vcr
dvd
2002
2002
2001
150
100
200
Region
East
East
East
Product Time
dvd
2001
dvd
2002
vcr
2002
East
West
dvd
dvd
2003
2001
Old s
100
150
100
200
New s
100
100
120
250
200
updated
upserted
Different dimensions:
Reference
Relate Models with different dimensions. Represent each as ndimensional array: one main, others as reference or lookup arrays.
Sales Table
c
p
USA
dvd
USA
tv
Poland vcr
France vcr
t
2001
2001
2001
2001
s
300.00 $
500.00 $
200.00 zl
100.00 fr
ratio
1
0.24
0.12
Different dimensions:
Reference
Sales Table
Conv table converts currency to $
c
p
USA
dvd
USA
tv
Poland vcr
France vcr
t
2001
2001
2001
2001
s
300.00 $
500.00 $
200.00 zl
100.00 fr
c
USA
Poland
France
ratio
1
0.24
0.12
2001
2001
2001
2001
300.00 $
500.00 $
48.00 $
12.00 $
Converted values
3
128
4
64
5
32
6
16
7
8
8
4
3
128
4
64
5
32
6
16
7
8
8
4
3
128
4
64
5
32
6
16
7
8
8
4
3
128
4
64
5
32
6
16
7
8
8
4
128
64
32
16
64
32
16
256
128
64
32
16
previous(s[1]) - s[1] = 4
SQL Model
Business Examples
y_ago
q_ago
m_ago
product
sales
1999m01
1998m01
1998m10
1998m12
1999m01
vcr
100.00
1999m02
1998m02
1998m11
1999m01
1999m02
vcr
120.00
1999q01
1998q01
1998q04
NULL
1999q01
vcr
360.00
For each row, we use the reference Model to find 3 other rows.
Sales cube: prod sales per y, q, m
t
product
sales
r_y_ago
r_q_ago
a_m_ag
o
1999m01
vcr
100.00
0.050
0.280
0.830
1999m02
vcr
120.00
1999q01
vcr
360.00
1998q04
vcr
370.00
For each row, we use the reference Model to find 3 other rows.
Sales cube: prod sales per y, q, m
t
product
sales
r_y_ago
r_q_ago
a_m_ag
o
1999m01
vcr
100.00
0.050
0.280
0.830
1999m02
vcr
120.00
0.055
0.330
1999q01
vcr
360.00
0.160
0.970
null
1998q04
vcr
370.00
For each row, we use the reference Model to find 3 other rows.
Sales cube: prod sales per y, q, m
t
product
sales
r_y_ago
r_q_ago
a_m_ag
o
1999m01
vcr
100.00
0.050
0.280
0.830
1999m02
vcr
120.00
0.055
0.330
...
1999q01
vcr
360.00
0.160
0.970
null
1998q04
vcr
370.00
null
interest
interest
F2
tax
F3
Output
Iterate till accuracy of .01
Account
salary
capital_gains
net
tax
interest
Balance
100,000
15,000
100,000
42,220
30,000
Output
Iterate till accuracy of .01
Account
salary
capital_gains
net
tax
interest
Balance
100,000
15,000
27,800
30,800
8,340
Output
Iterate till accuracy of .01
Account
salary
capital_gains
net
tax
interest
Balance
100,000
15,000
48,735
36,644
14,620
Financial Functions:
NPV
Cash_Flow table
year
prod
amou
nt
1999
vcr
100.0
0
2000
vcr
12.00
2001
vcr
10.00
2002
vcr
20.00
1999
dvd
200.0
0
2000
dvd
22.00
2001
dvd
12.00
npv
values i
(1 rate) i
amount
(1 rate) i
values i
amount
(1 rate) i
(1 rate) i
Cash_Flow table
year
prod
amou
nt
1999
vcr
100.0
0
2000
vcr
12.00
2001
vcr
10.00
2002
vcr
20.00
1999
dvd
200.0
0
2000
dvd
22.00
2001
dvd
12.00
npv
amount[1]/power(1+rate,1) + npv[1-1]
values i
amount
(1 rate) i
(1 rate) i
Cash_Flow table
year
prod
1999
vcr
amou
nt
100.0
0
2000
vcr
12.00
2001
vcr
10.00
2002
vcr
20.00
1999
dvd
200.0
0
2000
dvd
22.00
2001
dvd
12.00
npv
amount[2]/power(1+rate,2) + npv[2-1]
values i
amount
(1 rate) i
(1 rate) i
Cash_Flow table
year
prod
amou
nt
1999
vcr
100.0
0
2000
vcr
12.00
2001
vcr
10.00
2002
vcr
20.00
1999
dvd
200.0
0
2000
dvd
22.00
2001
dvd
12.00
npv
amount[3]/power(1+rate,3) + npv[3-1]
values i
amount
(1 rate) i
(1 rate) i
Cash_Flow table
year
prod
amou
nt
1999
vcr
100.0
0
2000
vcr
12.00
2001
vcr
10.00
2002
vcr
20.00
1999
dvd
200.0
0
2000
dvd
22.00
2001
dvd
12.00
npv
amount[i]/power(1+rate, i) + npv[i-1]
npv[ANY] ORDER BY i
= amount[ CV(i) ] / power(1+rate, CV(i))
+ npv[CV(i) 1]
(1 rate) i
prod
amou
nt
1999
vcr
100.0
0
2000
vcr
12.00
npv
100.0
0
-89.47
2001
vcr
10.00 -81.78
2002
vcr
20.00 -68.28
1999
dvd
200.0
0
200.0
0
2000
dvd
22.00
SQL Model
Performance
ANSI SQL version needs outer join for each formula plus a join for
reference model.
N formulas, M reference models N+M joins 4 joins in this example:
sales_cube time sales_cube sales_cube sales_cube
ANSI joins
350
300
250
200
SQL Model
150
100
50
10
11 12
13
14
Summary
New facility for spreadsheet-like computations
in SQL
High Performance
Collaborative analysis
Move external processing such as spreadsheets
into RDBMs for manageability and consolidation
Next Steps.
Demonstration at Oracle DEMOgrounds
Hands-on Lab
Reminder
please complete the
OracleWorld online
session survey
Thank you.
Q&
A
Q U E S T I O N S
A N S W E R S