0

Sales_fact:
Product_ID (FK)
价格

Dim_Product :
Product_ID
Product_Key
描述

我面临的问题是,如果我的产品可以属于多个类别,该怎么办。我应该在 Dim_Product 中为每个类别重复记录吗?

例子:

事实表:
Product_ID (FK):1
价格:10.5

Dim_Product :
Product_ID:1
Product_Key: ABC
描述: 笔记本电脑
Category_ID: 1

Product_ID:1
Product_Key:ABC
描述:笔记本电脑
Category_ID:2

Dim_Category:
Category_ID (FK):1
描述:HP

Category_ID (FK):2
描述:东芝

4

2 回答 2

0

对于这种情况,您需要的是雪花的对立面,它是产品和类别之间的桥梁。这个桥接表也将作为一个不真实的事实来显示哪些产品属于哪个类别。这在 Ralph Kimballs “The Data Warehouse Toolkit”的第 15 章中得到了展示

产品类别 桥梁

于 2012-03-23T00:44:04.957 回答
0

I would think that you would want to either move category information into dim_product, or allow for a link from the fact table to the category table, or have a different product_id key per category for those in multiple categories. As you have it displayed, there is no way to differentiate between the HP Laptop and the Toshiba Laptop. In fact a query would return both when linked as your tables are designed. I would recommend creating a different product_id for each unique Product_key, Description, Category_ID.

于 2011-11-04T15:05:31.273 回答