Use of Bridge Tables
Physical data modelling techniques transform
a many-to-many many-relationships into one-to many-relationships by adding additional
tables. These are referred to as bridge tables.
The bridge tables are primarily used for two reasons:
1-To solve the complexity in “Unbalanced hierarchy”.
2-To solve multivalued dimension problem.
Example
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))
SELECT TOP (1000) [CompanyKey]
,[ParentKey]
,[CompanyName] FROM [Bridge].[dbo].[Company]
You can read this relationship in two directions:
each company may have a parent company;
each company may be the parent of one or more companies.
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.
The second example and last is about multivalued dimension problem.
Another example
Benefits and Disadvantages
There are a number of advantages to creating bridge tables:
Properly joining the data streams that exist on each side of the bridge.
Filtering both data streams when a filter is applied on only one stream. If the data from one stream is properly associated with the other stream,
applying a filter on any column filters out a whole row of data. You can use detail filters and summary filters.
Avoiding double counting.
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