Bridge Tables
Bridge Tables
C om p a n
y1
C om p a n C om p a n C om p a n
y2 y3 y6
C om p a n C om p a n
y4 y7
C om pa n C om pa n
y5 y8
C om pa n
y9
Create Table Company (CompanyKey int, ParentKey int, CompanyName varchar(50))
,[ParentKey]
After this we may have questions about some reports. One of them may be:
Show me January orders from Company1 and any companies above it.
So, in a dimensional model, the idea is to support the study of facts (such as "order dollars") in the context of this hierarchy. This can be done using
a bridge table, as shown here:
Create a table called Orders(OrderKey, DateKey, ProductKey, SalesKey, CompanyKey) and table CompanyBridge(firstCompanyKey,
othersCompanyKey).
Each row contains a pair of company keys. Here are the rules for populating the bridge table:
For each company, the bridge contains rows associating it with each of its subordinates.
Each company also has 1 row associating it with itself. This allows us to select a single company on the
right (say Company Y) and aggregate all orders at or beneath that company.
There are several Disadvantages to the Bridge hierarchy method that need to be considered
Difficult to maintain
Becomes more complex with Slowly Changing Dimensions
May suffer poor performance with large data sets
The bridge table explodes in size due to ancestor combinations