.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Relationship between a dimension - two fact tables

Posted By:      Posted Date: August 29, 2010    Points: 0   Category :Sql Server
I have 3 fact tables and about 10 dimensions. I want to relate both "Fact_Pop1" and "Fact_pop2" to Dim_AgeGroup. But Fact_pop1 has single age group and Fact_pop2 has no single age group (5 years age group). I spent about a day on this but I could't solve it.   Fact_Pop1 Age        Race_key            Gender_key      Geography_key              Pop_size 10           White                    M                                            CA                          10000    10           White                    F        

View Complete Post

More Related Resource Links

PK to PK relationship between Fact and Dimension tables


Hi guys,

Is it possible to define a relationship between a Fact Table and Dimension Table using a PK to PK relationship rather than a PK FK relationship?

The reason I ask is that I'm working on building a cube, in which the tables I think I need to use as dimension tables only have matching Primary Keys in the current RDBMS, not a FK.

Is there any reason why I shouldn't use a PK to PK relationship?


Loading Dimension & Fact tables


Hello Experts,

I am new to SSAS & I need to load Dim & Fact tables for a data warehouse. I've the basic idea to load them, but i dont have the exact picture to load a fact table. For eg. if we have 3 dimension tables like Dim_Time / Dim_Geography / Dim_Product and one Fact Table Fact_Product as described in most of the online examples. Then how to load them. I know for fact Tables we need to do aggregations. But how to apply those aggregations on what criteria.  In the said example if we need to load Fact_Product then we should be able to see sales by product, sales for a given point in time & sales for a given geographic location. Then how to do that. Do we need to apply aggregate for all the dimension tables

I know i am not much clear, but i hope you guys can understand. If not please let me know i will try to explain it more. Please clear my doubts.

Thanks & Regards,


One-to-many relationship between Fact and Dimension - Help in Modelling


Hy from Portugal,

Well, here's my case to see if you can help me:
We are trying to build a DW in our Healthcare institution, however we are facing a challenge and we are not solving it using many-to-many dimension ( The technology is Microsoft).
Relational tables:
Fact Patient Hospitalization -  Each patient hospitalization generates an EPISODE of hospitalization (EPISODE_ID) WHICH IS UNIQUE ....in the relational fact table we have the EPISODE ID COLUMN and also a TOTAL_EPISODES column wich is always equal to "1" because, after dimensional modelling, we will have a measure that is "sum of episodes".
EPISODE_ID is a foreign key to the EPISODE_ID field of Patient Hospitalization Dimension 
Patient Hospitalization Dimensio
-> EPISODE_ID (primary key)
-> DESCRIPTION ( day or night - describes if the episode ocurred during the day or during the night)
Fact Patient Claims (this fact will be the basis for the measure "sum of claims")
This table has the fields
 -> CLAIM_ID ( it is always unique (p

How to specify ForeignKeyName for the relationship between fact table and dimension table?


The ForeignKeyName attribtute of a relationship is greyed and empty when I edit a relationship of a data source view in SQL Server 2008 BIDS.  How can I edit it?

Aggregation in many to many dimension -Fact relationship case


I have a Dimension A and Two fact Table F1,F2. Dimension A has many to many relationship with  fact table F1 Through intermediate Fact table F2.I want to have aggregation on Dimension A for Fact A 's related Measure .

How should I design  aggregation in such case ?


Parent-Child relationship on a Type 2 (SCD) Dimension

For a Type 2 slowly changing dimension (SCD) such as Employee with a Parent-Child relationship, how do you handle the explosion of new rows when a high ranking employee has an attribute change?   It will require terminating the high ranking employee row and adding a new current row with a new surrogate key. Then every employee row below this employee will also have to be terminated and a new current row added with the new surrogate key of the parent.   This will have to be performed 1 level at a time so the subordinate rows will have the new surrogate key of their immediate parent.   For a large organization such as 20,000 employees, this will result in a dimension with hundreds of thousands rows in a relatively short time.   Is there a better way to model this?

Getting counts by 2nd Date Dimension Attribute with Snapshot Style Fact Table

  I have an MDX question finding hard to solve.  I have a Snapshot Fact Table with a snapshot of the records in the source system for each batch date.  All records in the fact table are assigned the batch date with the batch date key.  There are many records for each day and each batch date is an entire copy of the source records.  So, the grain of the fact table is one record for each batch date that exists in the source system.  These facts rows have another date in them for when the record was entered.  This date is different from the batch date in that the batch date is based on the day the batch was processed and the entered date is based on when the record was entered.  If a record was entered many days before, its batch date will be today but its entered date will be several days ago.  Therefore each day a copy of all the records entered the previous batch date and all the records added on today's batch date are present. Fact Table : FactSnaphshotKey (surrogate for easier administration) BatchDateKey (link to batch date dimension – date dimension, first in dimension list so it is used for semi aggregate measures) EnteredDateKey (link to entered date dimension – date dimension) Facts Count – measure for fact table - default measure from Analysis Services cube 2 Dim

Non parent-child dimension with fact data at different levels... How!

Hi all, Quite new to SSAS, wondering if anyone could help with the following... I've got a dimension with attributes that indicate geographical location based upon UK postal boundaries - so ~1.8m Postcodes > ~10000 Postcode Sectors (PCDS) > ~3000 Postcode Districts (PCD) > ~100 Postcode Areas (PCA). The problem I have is that the address information is not of the highest quality. I have matched 50% of my facts to postcodes, of the remaining 50% i've mapped them to PCDS, PCD or PCA, where possible, leaving the lower-levels as NULL in those cases. My attribute hierarchy works fine where I have complete records all the way down the hierarchy, but I only have a single UNKNOWN member at the top (GOR) level. I want an UNKNOWN member at each level. It makes sense to me how to do this using a Parent-Child dimension, but i'm keen to avoid that as the performance is terrible. I'm hoping there's a method of configuring this. Any help massively appreciated.

Relationship to One of Several Tables

I'm building a website that has several areas where comments are allowed (general topics, activities, groups, etc.). I know I can create separate tables for each comment type. But I'm thinking it would be nice to be able to create one comment table that is used for all comment types. That would mean that, for any row in the comment table, it would be linked to one of several different tables. Some possible ways of approaching this include: 1. Include multiple foreign-key columns in my comments table. Only one would be used and the rest would be NULL. (All would be indexed.) 2. Have a single column that contains a foreign-key value and another column that indicates the comment type. In this case, there would be no relationship constraints established in the database. It would simply be enforced by my code. To get comments related to, for example, a specific activity, I would use something like WHERE ComParentID = @ActivityID AND ComType = TypeActivity. I'm not sure if this approach makes much sense. Perhaps someone could comment which of these approaches sound better, or suggest a different approach altogether. Thanks.Jonathan Wood • SoftCircuits • Developer Blog

Avoiding a SELECT distinct query generated by SSAS when using dimension derived from fact table

Hi, I am using a dimension derived out ot a fact table and the factt able primary key is dimension key. Issue is, there are large number of rows and so many attributes. SSAS issues distinct query and it takes large amount of time. Without the distinct statement, query takes only 3 min for 4 million rows. With the distinct, it takes 20 min. Becuase the fact primary key is the dimension key there is no need of a distinct statement. I know there is a option in the dimension to say "By Table" to avoid this. But unfortuantely, i breach the 4 GB limit for strings. Any suggestions for optimization? Thanks,  Sambath

Need multiple distinct counts, have 1 fact and 1 dimension

I am using SSAS 2005. I have 1 fact table and 1 dimension. I would like to create multiple distinct counts in 1 Measure group, at least I would like them to appear as in 1 measure group to end-user. I have tried role-playing dimensions, and a roll your own approach that work in limitation but didn't scale. Any help and advice would be great.

Join two fact tables




I have the following two fact tables, upon which a cube was built. As you can see, these two tables have most of the common (shared) dimensions except for ProductTypeID (product dimension) on fct_productsales table. The relationship between these two fact tables is 1(fct_loansales) to Many (fct_productsales).

When I browse these measures from the cube, they look fine (and break down perfectly) through all the shared dimensions.

However, when I try to filter or browse through product dimension (along with other dimensions), the measure values from fct_productsales will filter down correctly, but the values from fct_loansales does not change.  I tryied to create degenerate dimension from fct_loansales, but no luck. Any help is appreciated.



AccountNumber                       char

Bridge Table dimension or fact? updating from snapshots



Scenario: Bank Accounts and Customers. One Account can have many customers and many customers can have one joint Account. so its Many to Many relationship.

Special Scenaio: Bank provide us daily snapshot of all thier dimensions and facts, every night thier ETL run, and newsnapshot is available, previous is gone.

I am using SCD Transformation to update the dimensions, Type 1 for all the columns.

Tables1: DimAccounts (AccountsID(PK))

Table2:DimCustomers (CustomerID(PK))

Table3:DimBridge (AccountID (FK), CustomerID(FK), RelationShip (varchar10))

Question1: Are we supposed to treat bridge tables as Dimensions or Facts?

Question2:If it is to be treated as Dimension, How would I apply SCD Wizard to it, Since there are two business keys involved?

Question3: Do i need surrogate key in Bridge Table, like i have in other dimensions?

Thank You


Creating Local cube on Cube using Many-to-Many dimension relationship


Hi All,

I have got a cube that uses many-to-many dimensions relationship. I also have a calculated measure (A*B) in the measure group using a unary operator.

I tried creating the local cube by using CREATE GLOBAL CUBE statement and included the intermediate measure group and one measure from the group. I have also included all the dimensions that are linked to the intermediate measure group.

The local cube is being created but I don't see the correct values of the measures. I just get the value of A coming for the value of the calculated measures. There are also some performance issues while browsing the local cube which I assumed should be very fast.

I am not sure if this is a known issue and there's a solution available for this but I tried and didn't find anything on the forum. 

Please help me with this. Thanks in Advance.


Save Dimension member only when this have lines in Fact Table


I have one dimension table with over 600 item, but in my fact table only 40 of this member have lines (my fact have a filter for the 2 laste year)


How save on the dimension only this 40 members?


Best regards




Dimension key attribute changes in fact table



How do I need to handle a case in which the fields in a fact table that represent the foreign keys to the dimension tables might change? What kind of process do I have to do to the cube?



Map the start and end datetime fields of an historical dimension to the time dimension and the fact



I have a dimension with some historical attributes and I use start and end datetime fields to save the outdated records. I assume that when the cube is processed, each record in the fact tables is mapped to the matching record in the dimension by using the combination of the key attribute with the start and end datetime fields. My question is how to configure the mechanism so that it will know which field is the datetime field and use it to do the comparisons with the start and end fields?


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend