简体   繁体   English

维度建模-如何处理维度不一致的事实的单个事实表?

[英]Dimensional Modeling - How to deal with a single fact table with facts with inconsistent dimensions?

I want to set up a fact table for restaurant sales transactions. 我想为餐厅销售交易建立事实表。 Adding up the entire fact table will give the entire sales across the restaurant(s). 将整个事实表加起来将得出整个餐厅的全部销售额。 The restaurant has two main sources of revenue - food and beverage. 该餐厅有两个主要的收入来源-食品和饮料。 The dimensions for each are very different. 每个尺寸都大不相同。

For example, for food, I might want to track whether it's dairy free, gluten free, etc. Or I might want to see whether the dish is Italian, French, etc. For wine, I might be interested in the vintage, where the wine is from, what grape the wine is. 例如,对于食物,我可能想跟踪其是否不含乳制品,无麸质等。或者,我可能想查看该菜肴是否为意大利,法国等。对于葡萄酒,我可能对年份感兴趣,葡萄酒是从哪里来的?

How do I accomplish this with one fact table? 如何用一个事实表完成此操作? Should I simply have a Wine dimension that is NULL if the item is a food, and a Food dimension that is NULL if the item is a wine? 如果项目是食物,我是否应该简单地将Wine维度设置为NULL,如果项目是葡萄酒,则将Food维度设置为NULL?

Your fact probably looks something like this? 您的事实可能看起来像这样?

SALES_LINE_ITEM_FACT
   TRAN_DATE
   TRAN_HOUR (or other time buckets if needed)
   SERVER_KEY
   TABLE_KEY
   SEAT_KEY
   PROMOTION_KEY
   PRODUCT_KEY
   REGULAR_PRICE
   NET_SALE_PRICE
   PRODUCT_COST

Your "product" dimension is where you need to focus your attention on, if you want to report from a sales fact how many people ordered a specific wine. 如果要从销售情况中报告有多少人订购了特定的葡萄酒,则需要关注“产品”维度。

To start, it might just look something like: 首先,它可能看起来像:

PRODUCT_DIM
   PRODUCT_KEY
   PRODUCT_NAME
   PRODUCT_CATEGORY (food / beverage)
   PRODUCT_SUBCATEGORY (wine / beer / dairy / french / italian etc)
   CURRENT_AVERAGE_PRODUCT_COST

You could either add the detail information as another level on the category hierarchy, or if you want to do more detailed analysis, create specific snowflakes for certain product types and connect them to the product dim. 您可以将详细信息添加为类别层次结构的另一个级别,或者如果您想进行更详细的分析,则可以为某些产品类型创建特定的雪花,然后将其连接到产品昏暗处。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM