简体   繁体   中英

Designing fact table with mix granularities

I am designing a data model for reporting. 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 0 4
435 2 5
435 4 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.

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.

Are there any possible other way to keep both test and service detail in same fact? 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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