Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Revisiting Normal Forms
Message
From
21/11/1998 15:19:06
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00159608
Message ID:
00160197
Views:
21
>>One of my reasons is to keep calculated values in parent tables, though they may be recalculated from the child tables. Two reasons: first - there's always something which is added from the parent table (like one overall shipping cost, which can't be assigned to any specific line item)
>
>That in itself wouldn't be reason enough, since it doesn't prevent recalculation. You'd just add a shipping cost to the parent table. Yes, it's at least partially dependent on line items, but not completely.

Well, it's the invoice that's partially dependent, but the line items are also needed for other reports - like tracking the stock etc, where the shipping costs and taxes are irrelevant. Therefore I'm also denormalizing one more thing: the date is copied into line items, so they can have a tag on it for reporting purposes. This way, most of the reports don't need the parent table at all.

>>, second - the rules for calculating may change in time, and one is never too sure if pulling last year's data would yield the same result if today's rules apply.
>
>In that case, your schema is not denormalized at all, since the total amount is not wholly dependent on the line items. In a completely normalized schema, you'd have a Rules for Calculating table (which would be possible in VFP, if not in other environments),

I've had a table of rules in one version of salaries, but it actually contained source code in memo fields, so we simply re-generated a procedure file out of it. Later I've found I hacked this generated file too often, so I had to write a parser to propagate the changes back into the memos. If the first routine could be called a source code generator, the other one must be a degenerator :)

> but whether that would be worth it depends on the needs of the business. As you say, most of the time you don't need to recalculate at all (which, of course, begs the question that perhaps amounts aren't necessary in the line items table once the total has been calculated).

My principle is to calculate it only once, and in only one place, so they never catch me with two results of the supposedly same calculation. I regret every time I forget this rule. In most of the cases, this is what it really needs: an invoice or any other line item document is calculated only once, printed, sent and forgotten, but the line items themself are used further for various reports and other calculations, completely unrelated with invoicing.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Reply
Map
View

Click here to load this message in the networking platform