Re: Should I use one or two tables for summary data?

From: J.O. Aho <user_at_example.net>
Date: Mon, 6 Feb 2017 19:49:30 +0100
Message-ID: <efruprFf405U1_at_mid.individual.net>


[Quoted] On 02/06/17 16:51, Victor Porton wrote:
> Please advise:
>
> I need to store data grouped by days and by producers and also summary data,
> that is the result of SUM() (for all producers) grouped by days.
>
> Should I make two tables (one for producers data and one for summary one) or
> one table with `ProducerID IS NULL` indicating the summary data (sum for all
> producers)?

[Quoted] I would just make one table without any summary, when you need one you just run the SUM() on the grouping you want to know.

[Quoted] Keep a good index should make it fast when you want to summarize it.

This gives you the most flexibility.

If you prompt want to keeps aggregated data, then keep it in a separate table, don't forget to keep track of how you group the data if you have more than one way to group it.
[Quoted] This may require a third table with the grouping options and a fourth which links the second table with the grouping options in table three.

-- 

 //Aho
Received on Mon Feb 06 2017 - 19:49:30 CET

Original text of this message