simplify report generation by inserting bogus records with zero as value?
Date: 22 Apr 2002 18:12:07 -0700
Message-ID: <ea8a03ff.0204221712.57d924f5_at_posting.google.com>
I'm creating a database that tracks fuel use by facilities that generate electricity.
I can think of a few different way to do this. One that I have tried involves rather elaborate UNION queries that return zero value records where no records for a particular summing entity/fuel combination exist. This works but is cumbersome (hard to maintain the queries, less efficient execution).
An idea I had was to insert bogus records into the 'Generation' table for each potential summing entity (Plant Operator, State, SubRegion, Region)/fuel combination that would have a zero value in the 'MWh' and 'Consumption' columns. This would automatically generate a zero value for any summing entity/fuel combinations in aggregate queries where no other non-zero record exists, and wouldn't adversly effect queries where real records exist.
The only downside to this approach I can think of are that I will have to write a fairly complex INSERT query to make sure I cover all possible combinations of entity/fuel if I want to make sure this will always work--but I only have to do this once. But, it just seems like it's not a good idea to have bogus records in the table (even though they would be named such that their purpose would be obvious).
I'd appreciate opinions on the workability of this solution or suggested alternatives.
Thanks in advance,
ebradley4_at_yahoo.com Received on Tue Apr 23 2002 - 03:12:07 CEST