Bridge Table Flashcards
Bridge
Create a dimension which includes a weight factor and listagg.
CREATE TABLE leftDIM AS SELECT leftID, leftxxx, leftyyy, 1.0/count(rightID) as weightFactor, LISTAGG(rightID, ‘__’) WITHIN GROUP (Order By rightID) AS rightGroupList FROM (…) WHERE (…) GROUP BY leftID, leftxxx, leftyyy
What is the total cost for each right?
Select rightID, rightXXX, sum(totalCost * weight) AS total_cost_right FROM fact, left, bridge, right where fact.id = left.id and left.id = bridge.id and bridge.id = right.id group by rightID, rightXXX, order by rightID, rightXXX
Weightfactor
1.0/count(rightID) AS weightFactor
ListAGG
ListAGG(rightID, ‘__’) within group (order by rightid) as rightGroupList
ListAGG
ListAGG(rightID, ‘__’) within group (order by rightid) as rightGroupList
Create another version of a dimension with listagg and weight factor that has an increased level of aggregation
Create table leftDim as 1.0/count(rightID) as weightFactor, LISTAGG(rightID, ‘__’) within group (order by rightID) as rightGroupList from (…) where (…)
Create a bridge dim with increased aggregation using listagg
Create table bridgeDim as select listagg(rightID, ‘__’) within group (order by rightID) as rightGroupList, rightID from (…) where(…) group by rightID
Create a bridge dim
Select leftID, rightID from (…) where (…) group by leftID, rightID
Draw sample records for a ProductDim (ProdNo, ProdType) and Bridge (ProductNo, SupplierID) and SupplierDim (SupplierID, SupplierName) with weightFactor and listagg
draw