简体   繁体   English

相同的事实表列; 多因记录

[英]Same Fact Table Column; Records with Multiple Reasons

I am in a situation similar to the one below:我的情况类似于以下情况:

Think for instance we need to store customer sales in a fact table (under a data warehouse built with dimensional modelling).例如,我们需要将客户销售额存储在事实表中(在使用维度建模构建的数据仓库下)。 I have sales, discounts related to the sale, sales returns and cancellations to be stored.我有销售、与销售相关的折扣、销售退货和要存储的取消。

Do you think it would be advisable to store sales for a day to a customer in a particular product (when the day is the grain) as a positive value while the returns and discounts are stored as minuses?您认为将特定产品(当天是粮食)的一天的销售额存储为正值,而将退货和折扣存储为负值是否可取?

Also if a discount is enforced to a customer at a level other than the product (for instance brand), do you think it is alright to persist it with a key particularly assigned to the brand (product is the grain) while the product column being given an N/A, for the particular record?此外,如果对产品以外的其他级别的客户(例如品牌)强制执行折扣,您是否认为在产品列被指定时使用专门分配给品牌的键(产品是谷物)来持久化它是否可以?给定一个 N/A,对于特定的记录?

Thanks in advance.提前致谢。

If your sales are considered a good thing (I'm assuming they are) then recording sales as positive numbers makes perfect sense.如果您的销售额被认为是一件好事(我假设他们是),那么将销售额记录为正数是非常有意义的。 Any transaction that reduces sales (ie discounts and returns) should therefore be recorded as negative numbers.因此,任何减少销售额的交易(即折扣和退货)都应记录为负数。 This will make reporting your sales very natural.这将使您的销售报告非常自然。

If you have diffent dimensions that might account for a record, you should populate the dimensions that make sense.如果您有可能占记录的不同维度,则应填充有意义的维度。 So yes, attribute a discount to a brand rather than a product if that is what happened in your business transaction.所以,是的,如果您的业务交易中发生了这种情况,那么将折扣归因于品牌而不是产品。 This way your reporting will be able to look at all discounts, at discounts for particular products and discounts for entire brands.这样,您的报告将能够查看所有折扣、特定产品的折扣和整个品牌的折扣。 If your fact table shows the most direct "cause" of the discount (product or brand) then your reports will be more useful than if you link the fact to brand through a relationship to product.如果您的事实表显示折扣的最直接“原因”(产品或品牌),那么您的报告将比通过与产品的关系将事实与品牌联系起来更有用。

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

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