Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calculated field in free table
Message
De
22/02/2010 19:37:32
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01450377
Message ID:
01450389
Vues:
36
>>>Say we were working with a FREE table and wanted to have a calculated field where Field4 = Field1+Field2+Field3. I could do this with a form method triggered by the lost focus event for Fields 1-3, but is that the best way? Is there another way that would be more reliable similar to a stored procedure in a database table?
>>
>>Do you actually need to store the calculated value? There are some circumstances where that's appropriate, such as checksums for accounting or other purposes, or if the table(s) are huge and it's computationally too expensive to recalc the sums on the fly. But in many circumstances, storing a calculated result is considered bad practice because the sum may get out of sync with the contents of the other columns.
>>
>>IOW the most reliable way to keep the sum field updated is to not have one at all :)
>>
>
>I used to say the same type of thing (stored calculated fields bad). That has been modified somewhat to take the type of application into account. If the database is used in a CRUD application with frequent updates, the standard wisdom still applies IMO. But for relatively static databases, especially for OLAP use (often snapshots of the "real" database), stored calculated fields can offer a tremendous performance boost.

IOW we agree completely ;)
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform