[thelist] CF: Request for Opinion
rudy
r937 at interlog.com
Fri Sep 6 18:56:00 CDT 2002
> (or a table with a single record, ugh).
was that teensie-weensie troll aimed at me? okay, i'll bite
the ooak ("one of a kind") table concept has its advantages
for one thing, it makes the app portable
given that you do want an admin screen for these odds and sods pieces of
app data, it means you don't have to re-invent the esoteric code that
stores and manages this data in some external file, which surely will vary
from one scripting language to another -- just manage it like other
database data using sql calls, which is a pretty standard coding technique
that even junior coders should be comfortable with
next, and this is perhaps a "killer" advantage, consider how the data might
be used in the app
one example is exchange rate
in pulling out rows from, say, a product table, to convert the prices to
the user's currency, you simply join the ooak table into the query and
perform the calculation in sql
select product.description
, product.price * exchange_rate
from products, ooak
where product.pk in
( select cart.product_fk
from cart
where cart.userid= n )
note how this is a cross join, with no join conditions
that means every selected product row is joined with all the rows of the
ooak table -- all one of them!
no post-processing in your script to loop over records to perform the
calculation
i have conveniently glossed over matching the user to one of several
exchange rates, but the principle remains -- it is better to do this type
of calculation in sql
rudy
More information about the thelist
mailing list