Does surrogate key assignment for a fact table require that the source data has natural keys?
-
30-10-2019 - |
Question
Let's say I have a simple OLTP database with orders, products, and customers:
And from it, I am building a data mart with an orders fact table, product dimension, customer dimension, and date dimension:
When loading the orders table into fact_orders (let's say I was using an SSIS Lookup Transformation to assign the surrogate keys), does that mean that the source of data for the orders would also need to have the natural "foreign key" values that were associated with the order in the OLTP system?
In other words, would the data that's being loaded come from a query like this?
SELECT
order_date, -- needed to get date surrogate key
customer_name, -- needed to get customer surrogate key
product_name, -- needed to get product surrogate key
order_number, -- denegenerate dimension,
qty_ordered AS order_qty, -- measure
total_amount AS order_amount -- measure
FROM orders o
INNER JOIN customers c
ON o.customer_id = c.customer_id
INNER JOIN products p
ON o.product_id = p.product_id
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange