SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Use the surrogate key


Use the surrogate key

Author
Message
imani_technology
imani_technology
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1764 Visits: 787
Here is the scenario. I have a fact table that looks like the following:

factEmployeeWorkHours
PK ID
LastName
FirstName
Hours

The fact table joins to a dimension table that looks like the following:

dimOrganization
PK ID
EmployeeLastName
EmployeeFirstName
Store
StoreManager
RegionalManager
VP
Region
State

But there is a problem. The Employee can be assigned to more than one store and therefore can have more than one store manager, region, etc. If I join the fact table to the dim table during ETL to get the surrogate key/PK from the dim table, I will have multiple PKs per fact table row. I know that Kimball wants to have an FK in the fact table that joins the PK in the dimension table, but is that prudent in this case?
PaulB-TheOneAndOnly
PaulB-TheOneAndOnly
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14405 Visits: 4639
imani_technology (11/5/2012)
Here is the scenario. I have a fact table that looks like the following:

factEmployeeWorkHours
PK ID
LastName
FirstName
Hours

The fact table joins to a dimension table that looks like the following:

dimOrganization
PK ID
EmployeeLastName
EmployeeFirstName
Store
StoreManager
RegionalManager
VP
Region
State

But there is a problem. The Employee can be assigned to more than one store and therefore can have more than one store manager, region, etc. If I join the fact table to the dim table during ETL to get the surrogate key/PK from the dim table, I will have multiple PKs per fact table row. I know that Kimball wants to have an FK in the fact table that joins the PK in the dimension table, but is that prudent in this case?


It all comes down to granularity.

If business requirements call for collecting the employee hours not matter where the employee was working then you shouldn't care about different stores, different managers, etc.

If business requirements call for collecting detailed information about where and with who the employee was working then the design lacks much needed columns to go down to such granularity.

Either way, the design of the fact table (for starters) looks a bit fuzzy to me. Either that fact table expects to have a single row per employee which is the same as saying that the table is not a fact table but a summary table OR, table expects to store as many rows as needed for employee so to track where the employee has worked... in this case having the name of the employee on each row is really not a good idea.

Would you please give more details?

_____________________________________
Pablo (Paul) Berzukov

Author of Understanding Database Administration available at Amazon and other bookstores.

Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
Bruce W Cassidy
Bruce W Cassidy
Hall of Fame
Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)

Group: General Forum Members
Points: 3135 Visits: 1033
imani_technology (11/5/2012)
Here is the scenario. I have a fact table that looks like the following:

factEmployeeWorkHours
PK ID
LastName
FirstName
Hours


Is there a reason why you don't have an employee dimension? That way on your fact table, you could have two dimensions (one for employee, one for store), and employees could work quite happily across multiple stores without it being problematic.

You would end up with a structure on your fact table such as:

factEmployeeWorkHours
PK ID
Employee Dimension Key
Store Dimension Key
Hours


There's a common misconception that dimensional data warehouses are not normalised. While there is some truth in that, it's better to think of them as denormalised in specific cases. In general, fact tables are heavily normalised. That means that if you have repeated sequences within a fact table, the chances are you are missing a dimension.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search