简体   繁体   English

设计具有混合粒度的事实表

[英]Designing fact table with mix granularities

I am designing a data model for reporting.我正在设计一个数据 model 用于报告。 In the source there are three tables which has to be considered.在源代码中,必须考虑三个表。

Invoice table Test table Services table发票表 测试表 服务表

Test and services are against an invoice.测试和服务是针对发票的。 One invoice can have multiple test as well as multiple services.一张发票可以有多项测试和多项服务。

eg:例如:

InvoiceId发票编号 TestCount测试计数 ServicCount服务计数
123 123 0 0 4 4
435 435 2 2 5 5
435 435 4 4 2 2

To calculate total revenue total amount column in the invoice table can be referred.计算总收入总金额列可参考发票表。 But for the net revenue.但是对于净收入。 Sum of the Testcost column in Test table and Servicescost column in service cost has to be calculated.必须计算 Test 表中的 Testcost 列和 service cost 中的 Servicescost 列的总和。

When designing a fact table for Tests and services.在为测试和服务设计事实表时。 I think it's better to go with two fact tables one for test and one for service as they have different granularities and when reporting create a measure to calculate both and get the total net revenue.我认为 go 最好使用两个事实表,一个用于测试,一个用于服务,因为它们具有不同的粒度,并且在报告时创建一个度量来计算两者并获得总净收入。

Are there any possible other way to keep both test and service detail in same fact?是否有任何其他可能的方法可以将测试和服务细节保持在同一事实中? ie. IE。 mix of granularities in one single fact?在一个事实中混合粒度?

Any valuable insight please请任何有价值的见解

Thanks in advance提前致谢

Mixing facts of different grains in the same fact table is about as big a mistake as it is possible to make when designing a fact table.在同一个事实表中混合不同粒度的事实几乎是设计事实表时可能犯的最大错误。

So, no, it is not possible to keep facts with different grains in the same fact table.所以,不,不可能将具有不同粒度的事实保存在同一个事实表中。

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

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