dbTalk Databases Forums  

Database and Calculations

comp.databases.xbase.fox comp.databases.xbase.fox


Discuss Database and Calculations in the comp.databases.xbase.fox forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Boulent Mustafa
 
Posts: n/a

Default Database and Calculations - 08-10-2004 , 09:08 AM






Using Visual Foxpro 3, I have a field within my database and the value
of the field is determined by a calculation of data from other fields
in the same database.

Where is the best place to perform this calculation and where is the
best place to insert the code that will perform the value assignment.

Kind Regards,
Boulent

Reply With Quote
  #2  
Old   
Rick Bean
 
Posts: n/a

Default Re: Database and Calculations - 08-10-2004 , 01:25 PM






First, that's usually not good database design - if you can calculate the data from other data in the same row (record), then you shouldn't store it, since it'll need to be updated anytime the dependent fields are changed. Just compute it when you need it.

If you must calculate it, then you could use the database to use field validations to update the dependent field. Or if it isn't system w4ide, you could put it in a form user method.

Rick

"Boulent Mustafa" <OhWhite (AT) hotmail (DOT) com> wrote

Quote:
Using Visual Foxpro 3, I have a field within my database and the value
of the field is determined by a calculation of data from other fields
in the same database.

Where is the best place to perform this calculation and where is the
best place to insert the code that will perform the value assignment.

Kind Regards,
Boulent

Reply With Quote
  #3  
Old   
Boulent Mustafa
 
Posts: n/a

Default Re: Database and Calculations - 08-11-2004 , 02:55 AM



"Rick Bean" <rgbean (AT) NOSPAMmelange-inc (DOT) com> wrote

Quote:
First, that's usually not good database design - if you can calculate
the data from other data in the same row (record), then you shouldn't
store it, since it'll need to be updated anytime the dependent fields
are changed. Just compute it when you need it.

If you must calculate it, then you could use the database to use field
validations to update the dependent field. Or if it isn't system w4ide,
you could put it in a form user method.

Rick
Unfortunately that is the problem. Its been ten years since I last
used Foxpro and it is the only database development tool I am even
slightly familiar with.

Hence the problem I am having is knowing where and how to perform the
calculations outside the database structure.


Reply With Quote
  #4  
Old   
Stefan Wuebbe
 
Posts: n/a

Default Re: Database and Calculations - 08-11-2004 , 03:30 AM




"Boulent Mustafa" <OhWhite (AT) hotmail (DOT) com> schrieb im Newsbeitrag
news:30822987.0408102355.4221afad (AT) posting (DOT) google.com...
Quote:
"Rick Bean" <rgbean (AT) NOSPAMmelange-inc (DOT) com> wrote

First, that's usually not good database design - if you can calculate
the data from other data in the same row (record), then you shouldn't
store it, since it'll need to be updated anytime the dependent fields
are changed. Just compute it when you need it.

If you must calculate it, then you could use the database to use field
validations to update the dependent field. Or if it isn't system w4ide,
you could put it in a form user method.

Rick

Unfortunately that is the problem. Its been ten years since I last
used Foxpro and it is the only database development tool I am even
slightly familiar with.

Hence the problem I am having is knowing where and how to perform the
calculations outside the database structure.
If you want to have it in one place, one option is to use Views
and bind your controls to them (instead of the table aliases
themselves).
Create View vCustomers as ;
Select *, ;
fieldX + fieldY As CalculatedColumn ;
From customers

Many other options though, e.g. alternatively, you can also have
grid.Columns containing an expression in their ControlSource
property.
Or use singleTextbox.Refresh() to calculate a value etc. ...


hth
-Stefan



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.