Re: Is there a way?
- From: Dale Fye <dale.fye@xxxxxxxxxx>
- Date: Wed, 24 Sep 2008 09:39:01 -0700
Bob,
I would agree that there are instances when storing a computed value
actually does make sense.
Another good example would be an inventory database. I could always
calculate the expected number of items on hand on a given date, but to do so,
across an enterprise would be time consuming. So, occassionally, we store
the expected inventory, along with the actual inventory in a table. That
way, I don't have to compute all of the purchases and sales up to that date
when I want to analyze the difference between expected and actual inventories
(over time).
--
Dale
email address is invalid
Please reply to newsgroup only.
"Bob Barrows [MVP]" wrote:
True, for birth date. For historical age, however, storing the record's.
creation date would require calculating the age on the fly, which might
impair performance.
What I'm arguing for of course, is the idea that storing the result of a
calculation whose result will never change is not necessarily a bad
thing. Especially if the calculation is time-consuming.
Michel Walsh wrote:
Sorting on age would be the same as sorting on date of birth.
Filtering is another matter, but you can filter on a computed
expression NOT involving the field:
Instead of
WHERE DateAdd("yyyy", 18, dateOfBirth) <= Now( )
can be
WHERE dateOfBirth <= DateAdd("yyyy", -18, Now( ) )
which and make the computation just once, and will be able to use
index, if any, on dateOfBirth.
Vanderghast, Access MVP
"Bob Barrows [MVP]" <reb01501@xxxxxxxxxxxxxxx> wrote in message
news:ORJeEmlHJHA.4600@xxxxxxxxxxxxxxxxxxxxxxx
Tom Lake wrote:
"deepak" <deepak@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message... unless
news:3CB45E3C-8D62-4CC3-A411-A06FB592FBE8@xxxxxxxxxxxxxxxx
Hi!
Sppose I make two tables tblName and tblAge. tblName has two
fields name and address. And tblAge has two fields age and
telephone no.
I wouldn't store Age in a table. You'd have to update it every
year! You should probably store a date and calculate Age as you
need it.
a) you need to know the Age at the time the record was created, or
b) you need to filter/sort data by age. Having the age stored vs
having to calculate it can potentially make a large difference to
performance
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get
a quicker response by posting to the newsgroup.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
- References:
- Is there a way?
- From: deepak
- Re: Is there a way?
- From: Tom Lake
- Re: Is there a way?
- From: Bob Barrows [MVP]
- Re: Is there a way?
- From: Michel Walsh
- Re: Is there a way?
- From: Bob Barrows [MVP]
- Is there a way?
- Prev by Date: Make Table Field Definition
- Next by Date: Re: Make Table Field Definition
- Previous by thread: Re: Is there a way?
- Next by thread: extract value from a query field
- Index(es):
Relevant Pages
|