Quote:
quote:Originally posted by jobalistic
...
I need to store the SUM field because I need to a summation on this field whenever the user inputs a value. In other words, I need to do a another calulation just for the SUM field that is why I need to store this value in the table.
|
You really should read up on the concept of
normalization. The first rule of normalization is that all data is
atomic; that is, data is not repeated, and is not a composite made of other data elements.
The reason why this rule exists is that it is just too easy for such composite data to get 'out of sync' with the data which comprises it. If you have some process somewhere which updates, say, column NUMBER1 and doesn't 'remember' (or otherwise 'know') that NUMBER1 is not only a piece of data in its own right, but is also a component of some other column (e.g. SUM), then your data has just become corrupt. Worse, you'll have virtually no evidence that this data is wrong until somebody notices someday that things don't add up. You'll also have no idea which process or program caused the corruption or when it occurred, making for a
very difficult debugging chore.
You claim you need this column because you have to sum on it, but it's a simple matter to sum the component columns as, e.g:
Code:
SELECT SUM(Col1 + Col2) FROM ...
or otherwise include its components in any other expression.
Jeff Mason
Custom Apps, Inc.
www.custom-apps.com