Is it better to have fewer tables with more columns or more tables with fewer columns?
For example lets say I have one table where the columns are
Date, Hour, Market, Price
Hour just means the hour of the day (ie. 1-24). Market is a three character code either DAM or RTM. Price is the important value to track.
Would it be better to instead have two tables with just three columns where one of the tables is the subset where market is DAM and the other is RTM?
Another idea is to make the table with Date, Hour, DAMPrice, RTMPrice. Would this be the best given that most selects would be simpler with this approach?
The most used SELECT is to take the difference of the DAMPrice from the RTMPrice which now works with joins on the same table.
From a design perspective, it’s usually better to normalize your data to reduce redundancy. Usually this means more tables with fewer columns.
In practice, however, you’ll get better performance if you minimize the number of join operations. So it may be acceptable to have redundant data if you want to speed up your reads. In this situation you would have fewer tables with more columns.
I recommend choosing the better design first, then optimizing for performance later if necessary.