Академический Документы
Профессиональный Документы
Культура Документы
Demystified
Elizabeth Snow-Trenkle
Rocky Mountain Cognos User Group Meeting
May 17, 2013
1
Topics
Introduction to Joins
1..1 “The Inner Join”
0..1 “The Outer Join”
Classifying the “Fact” Table
1..n “The Fact Table”
0..n “The Outer Fact Table”
Considerations
2
Introduction to Joins
3
Underlying Tables
Consider the following tables:
4
Requirement/Goal
5
1..1 “The Inner Join”
6
1..1 “The Inner Join”
Expected
Actual
7
1..1 “The Inner Join”
Examine the SQL
select
Patient.PatientId as PatientId,
XSUM(charge.ChargeAmt for Patient.PatientId ) as ChargeAmt,
XSUM(payments.PaymentAmt for Patient.PatientId ) as PaymentAmt
from
Test.Test.dbo.Patient Patient,
Test.Test.dbo.charge charge,
Will count 2x payments
Test.Test.dbo.payments payments
where
because there are 2
(Patient.PatientId = charge.PatientId) and
charges.
(Patient.PatientId = payments.PatientId)
group by
Patient.PatientId
8
0..1 “The Outer Join”
Returns all rows from the left table in conjunction with
matching rows from the right table.
9
0..1 “The Outer Join”
Expected Actual
10
0..1 “The Outer Join”
Examine the SQL
select
Patient.PatientId as PatientId,
XSUM(charge.ChargeAmt for Patient.PatientId ) as ChargeAmt,
XSUM(payments.PaymentAmt for Patient.PatientId ) as PaymentAmt
from
Test.Test.dbo.Patient Patient
left outer join
Test.Test.dbo.charge charge
Will count 2x payments
on (Patient.PatientId = charge.PatientId) because there are 2
left outer join charges.
Test.Test.dbo.payments payments
on (Patient.PatientId = payments.PatientId)
group by
Patient.PatientId
11
Classify the “Fact” Table
12
1..n “The Fact Table”
13
1..n “The Fact Table”
14
1..n “The Fact Table”
15
0..n “The Outer Fact Table”
16
0..n “The Outer Fact Table”
17
Considerations
Tuning:
Indexes should be evaluated based on the sub-
queries they create
Ignore the very misleading FM Relationship Impact
description:
18
Conclusion
19
Questions?
20