Avoid role play dimension in DW

View previous topic View next topic Go down

Avoid role play dimension in DW

Post  MMS on Sun Oct 12, 2014 10:09 pm

Hi All ,

I'm new in this forum and this will be my first post , hope put my query in a right place:)
I have 3 Fact tables all have different Date and time fields , Priority and Address  

- Fact A ( DateTime 1, DatTime 2, DateTime 3,Priority1 , Priority2 ,Priority3,CountRowNumA )
- Fact B ( DateTime 4 , DateTime 5,Address1,CountRowNumB)
- Fact C  (DateTime7, Priority4,Address2,Address3,CountRowNumC)

So have 4 Dimension tables:
-Date ( keeping Date , Year , Month , week and etc.)
-Time ( keep 1 hours , 30 minutes , 10 minutes Interval )
-Priority  ( Priority ID )
-Address ( Suburb Name )

The main query of these table would be something like :
- Show CountRowNumA ,CountRowNumB,CountRowNumC for 1/2/2014 and Priority ID equal to 2 and Suburb Name = 'BBBBB'

If I create dimensions with role play then users will forced to pass parameters for each date/time/Priority /Address and it should be only one single query entry .

Would it be advisable way for cover these type of queries ?

Thanks .

MMS

Posts : 3
Join date : 2014-10-12

View user profile

Back to top Go down

Re: Avoid role play dimension in DW

Post  MMS on Mon Oct 13, 2014 9:36 pm

Please let me know if it in not clear .

MMS

Posts : 3
Join date : 2014-10-12

View user profile

Back to top Go down

Re: Avoid role play dimension in DW

Post  BoxesAndLines on Mon Oct 13, 2014 11:11 pm

When I'm looking for rows where priority = 'ABC' in fact A, do I need to to query all three priority relationships? If so, then what you really have is a multi-valued column that is better suited to a bridge table.
avatar
BoxesAndLines

Posts : 1212
Join date : 2009-02-03
Location : USA

View user profile

Back to top Go down

Re: Avoid role play dimension in DW

Post  nick_white on Tue Oct 14, 2014 2:35 am

Dimensional roles are basically just DB aliases. If you reference the same table more than once in a query then you have to alias it (this is not specific to querying star schemas). Assuming that a query parameter is used in multiple places in the query, if you put the query in a Stored Procedure or use a BI Tool you can probably get away with only entering a parameter value once (as you are hiding the complexity from the users) but if you let your users execute raw SQL (which is not a good idea - but that's another conversation) then they would have to enter the values multiple times

nick_white

Posts : 366
Join date : 2014-01-06
Location : London

View user profile

Back to top Go down

Re: Avoid role play dimension in DW

Post  MMS on Wed Oct 15, 2014 2:02 am

BoxesAndLines and  nick_white thank you for replying .

What Data Analyst wants to see in report is Priority as dimension and when put each of measures against it , see the amount of measured that picked from related Fact Tables . So as an example when he pick Priority  AA,BB and CC then


" />

MMS

Posts : 3
Join date : 2014-10-12

View user profile

Back to top Go down

Re: Avoid role play dimension in DW

Post  nick_white on Wed Oct 15, 2014 8:14 am

Your design of Fact Table A doesn't make it easy to produce this sort of report but it can be done using multiple SQL statements:

SELECT PRIORITY1, 'FactA-Priority1', SUM(CountRowNumA)
FROM FactA
WHERE PRIORITY1 IN ('AAA','BBB','CCC')
UNION
SELECT PRIORITY2, 'FactA-Priority2', SUM(CountRowNumA)
FROM FactA
WHERE PRIORITY2 IN ('AAA','BBB','CCC')
UNION
SELECT PRIORITY3, 'FactA-Priority3', SUM(CountRowNumA)
FROM FactA
WHERE PRIORITY3 IN ('AAA','BBB','CCC')
UNION
SELECT PRIORITY4, 'FactC-Priority4', SUM(CountRowNumC)
FROM FactC
WHERE PRIORITY4 IN ('AAA','BBB','CCC')

To make it easier to produce this type of report you probably need to re-design (or create a new) fact table that has a single reference to the Priority Dim and also includes a Priority Type Dim (or include Priority Type in the Priority Dim as a hierarchy)

nick_white

Posts : 366
Join date : 2014-01-06
Location : London

View user profile

Back to top Go down

Re: Avoid role play dimension in DW

Post  Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum