3. JSOM, UT Dallas
3
• SLIGHTLY RAGGED • RAGGED
JSOM, UT Dallas
3
2) Variable Depth Hierarchy
4. JSOM, UT Dallas
4
RECURSIVE POINTER
• Way to represent parent/child tree structure.
• Points from child node to parent node.
1
2
4 5
3
6 7
8 9
Recursive
Pointer
5. JSOM, UT Dallas
5
1
2
4 5
3
6 7
8 9
PROBLEM 1 : ROLL UP ISSUE
•Roll- ups don’t end up at same level
•They are complex and slow.
6. JSOM, UT Dallas
6
PROBLEM 2 : SHARED OWNERSHIP
1
2
4 5
3
6 7
8 9
• Consider 60% ownership of 5 and
40% ownership of 6.
• Paths have to be modified.
7. JSOM, UT DallasT
7
1
2
4 5
3
6 7
8 9
PROBLEM 3 : ORGANISATIONAL CHANGE
• Major changes in the paths have to be
made.
• Reporting of past and future becomes
an issue.
The need to solve these problems brings us to the solution- the Bridge table!
8. Bridge Table
• Essentially ‘bridges’ a dimension and fact table.
• Preserves contents of dimensions and facts in raw form.
• Solving the previously discussed problems of the recursive
solution.
JSOM, UT Dallas
8
Organization
Dimension
Organization Key (PK)
Organization Name
Organization Location
…
Organization Map Bridge
Parent Organization Key (FK)
Child Organization Key (FK)
Depth from Parent
Highest Parent Flag
Lowest Child Flag
General Ledger Fact
Account Key (FK)
Organization Key (FK)
…
…
Amount
Balance
9. Bridge Table - Structure
• Record whole rollup structure
• Define its grain as each path in the tree
JSOM, UT Dallas
9
1
2 5
3 4
Parent
Key
Child Key Depth
from
parent
Highest
parent
flag
Lowest
child flag
1 1 0 Y N
1 2 1 Y N
1 3 2 Y Y
1 4 2 Y Y
1 5 1 Y Y
2 2 0 N N
2 3 1 N Y
2 4 1 N Y
3 3 0 N Y
4 4 0 N Y
5 5 0 N Y
10. Bridge Table – Shared ownership variant
• Department 4 outsources 60% of its work to another department 5.
• Example of a shared
ownership.
JSOM, UT Dallas
10
1
2 5
3 4
Parent
Key
Child
Key
Depth
from
parent
Highest
parent
flag
Lowest
child
flag
Owners
hip
Percent
1 1 0 Y N
1 2 1 Y N
1 3 2 Y Y
1 4 2 Y Y
1 5 1 Y Y
2 2 0 N N
2 3 1 N Y
2 4 1 N Y 40%
3 3 0 N Y
4 4 0 N Y
5 5 0 N Y
5 4 1 N Y 60%
11. JSOM, UT Dallas
11
Bridge Table – Shared ownership variant
• Department 4 outsources 60% of its work to another
department 5.
• Example of a shared
ownership.
JSOM, UT Dallas
11
1
2 5
3 4
Parent
Key
Child
Key
Depth
from
parent
Highest
parent
flag
Lowest
child
flag
Ownership
Percent
1 1 0 Y N
1 2 1 Y N
1 3 2 Y Y
1 4 2 Y Y
1 5 1 Y Y
2 2 0 N N
2 3 1 N Y
2 4 1 N Y 40%
3 3 0 N Y
4 4 0 N Y
5 5 0 N Y
5 4 1 N Y 60%
12. JSOM, UT Dallas
12
JSOM, UT Dallas
12
Bridge Table – Shared ownership variant
• Department 4 outsources 60% of its work to another
department 5.
• Example of a shared
ownership.
JSOM, UT Dallas
12
1
2 5
3 4
Parent
Key
Child
Key
Depth
from
parent
Highest
parent
flag
Lowest
child
flag
Ownership
Percent
1 1 0 Y N
1 2 1 Y N
1 3 2 Y Y
1 4 2 Y Y
1 5 1 Y Y
2 2 0 N N
2 3 1 N Y
2 4 1 N Y 40%
3 3 0 N Y
4 4 0 N Y
5 5 0 N Y
5 4 1 N Y 60%
13. JSOM, UT Dallas
13
Bridge Table - Advanced
• Handle time varying ragged hierarchies
JSOM, UT Dallas
13
1
2 5
3 4
1
2 5
3 4
Before 11/01/16
After 11/01/16
14. Bridge Table – Advantages
• Offers exceptional flexibility
• Accommodates SCD type 2 changes
• Accommodates tree structure changes
JSOM, UT Dallas
14
15. A quick revisit!
JSOM, UT Dallas
15
Problems Solution
1. Slow rollup issues Percent ownership column
2. Multiple parents Begin and end dates
3. Organizational changes Lowest child-flag
From the original Dimension table or Fact table, we can’t find out the relationship between organizations. In the future, your boss might ask you to create a report for your department including all the small part. Then how can you aggregate these information? Answer is using Bridge Table
Bridge table is a table to connect dimension table and Fact table contain all father-children relationship between organizations.
Added :
Bridge table preserves the contents of the dimension as well as the fact tables just as they are. Unlike the recursive relationships, where organizations were regarded as SCDs and a change in a parent node carried the risk of altering the entire branch, we don’t have to deal with that problem here.
Take this simple tree structure to explain how does a bridge table work
5 nodes, one root node, 3 leaf nodes, one branch named a node with at least one child
Paths, each record presents one path
All self reference relationships (5)
1 depth relationships (4)
2 depth relationships (2)
4. Explain the Root flags, Leaf flags in detail.
Say if 1,2,3, 4 and 5 are independent orgs. In an enterprise. To find total sales for Org 2, you would have to show total sales of Org 2, Org 3 as well as Org 4.
Shared ownership
Note that the 5th row also become a parent to the 4th row since the 5th organization is also a 50 per cent shareholder of the 4th organization. The last highlighted row shows the same.
SCD (Slightly Change Dimension)
List down the advantages.