Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Star Schema with Multiple Outer Joins - Help!
I must admit that it took me a while to figure out what you might be trying
to do.
Its always prudent to also provide a simplification of your problem (next to
the actual
problem) .. and provide data specific details as to what you are trying to
achieve.
Essentially you are asking for a cartesian join between the dimension tables and then want to join it (outer) with the fact table. You want to do this to find out which combination does not exist in the fact table. If I am correct in my assumption, read on.
I have simplified the problem ... but I guess you will get the idea ....
avarma> select * from x1; -- Fact Table
A B C
---------- ---------- ----------
1 19 1 2 20 1
avarma> select * from f1; -- Dimension Table
A A_DESC
---------- ----------
1 1_desc 2 2_desc 3 3_desc
avarma> select * from f2; -- Dimension Table
B B_DESC
---------- ----------
19 19_desc 20 20_desc
avarma> select a_desc, b_desc, c from x1, f1, f2 2 where f1.a = x1.a(+) and f2.b = x1.b(+); where f1.a = x1.a(+) and f2.b = x1.b(+)
*
ERROR at line 2:
ORA-01417: a table may be outer joined to at most one other table
^^^^^ You are trying this avarma> select a_desc, b_desc, nvl(c,0) from avarma> (select a, a_desc, b, b_desc from f1, f2) dimen, -- Do cartesian join for all combinations avarma> x1
A_DESC B_DESC NVL(C,0)
---------- ---------- ----------
1_desc 19_desc 1 1_desc 20_desc 0 2_desc 19_desc 0 2_desc 20_desc 1 3_desc 19_desc 0 3_desc 20_desc 0
6 rows selected.
Though it beats me as to why you would want to do this
(unless of course, if I'm wrong in my assumptions) ... a cartesian join of 6
dimension
tables might be huge!
Anurag
"Gary Karpoff" <gary-k_at_vips.com> wrote in message
news:aft03v$2g1$1_at_news.umbc.edu...
> How's this for a conundrum! I'm fairly new to Oracle and far from a SQL
> expert and I will be forever grateful to any Oracle wizard out there who
can
> help with this challenge. My data model is a star schema with
> MSM_TEST_STATE_SMRY_FACT as the fact table and 17 related dimension
tables.
> Each row in the fact table has the key values for all 17 dimensions
> (STATE_ID, PRD_ID, AGE_GRP_ID, RACE_ETHNCTY_ID, SEX_ID, MAS_ID, BOE_ID,
> SCHIP_ID, DUAL_ELGBL_ID, SRVC_CTGRY_ID, SRVC_TYPE_ID, CLM_TYPE_ID,
> PGM_TYPE_ID, PLAN_TYPE_ID, MDCR_XOVER_ID, ADJSTMT_IND_ID, AND CNTY_ID)
along
> with various facts (UNIQ_ELGBLS_CNT, UNIQ_BENE_CNT, etc.). The only fact I
> am concerned about is UNIQ_ELGBLS_CNT. The fact table rows consist of only
> those combinations of dimensions that have related fact values (for
example,
> if the combination where all dimensions [STATE_ID through CNTY_ID] are
equal
> to 1 would result in a null value for UNIQ_ELGBLS_CNT, there is simply no
> row containing this combination of dimension values in the fact table). I
> need to create a view that contains every possible combination of 6
> dimension values from the dimension tables along with corresponding values
> for UNIQ_ELGBLS_CNT from the fact table. In those cases where the
> combination of dimension IDs does not exist in the fact table, I need to
> create a row containing the dimension values from the dimension tables
along
> with a zero for the UNIQ_ELGBLS_CNT fact.
>
>
![]() |
![]() |