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
Best Answer
I'm not sure that you need "natural" keys, but you probably do need to maintain a key mapping of sorts. So you need to understand what relationships map between your source and target systems, identify the keys for those relationships and build your key mappings from there.
I had a previous question on this called "What is the best practice for mapping from natural keys to integer-based keys? (ETL)".