I have a recursive hierarchy in a relational database, this reflects teams and their position within a hierarchy.
I wish to flatten this hierarchy into a dimension for data warehousing, it's a SQL Server database, using SSIS to SSAS.
I have a table, teams:
teamid Teamname
1 Team 1
2 Team 2
And a table teamhierarchymapping:
Teamid heirarchyid
1 4
2 2
And a table hierarchy:
sequenceid parentsequenceid Name
1 null root
2 1 Level 1.1
3 1 Level 1.2
4 3 Level 1.2 1
Giving
Level 1.1 (Contains Team 2)
root <
Level 1.2 <
Level 1.2 1 (Contains Team 1)
I want to flatten this to a dimension like:
Team Name Level 1 Level 2 Level 3
Team 1 Root Level 1.1 [None]
Team 2 Root Level 1.2 Level 1.2 1
I've tried various nasty sets of SQL to try and bring that together, and various piping around in SSIS (which I am just starting to pick up), and I'm not finding a solution that brings it together.
Can anyone help?
(Edit corrected issue with sample data, I think)