Re: Storing units in the database

From: Mikito Harakiri <mikharakiri_nospaum_at_yahoo.com>
Date: 12 Jul 2005 14:34:38 -0700
Message-ID: <1121204072.986506.317440_at_o13g2000cwo.googlegroups.com>


Marshall Spight wrote:
> Mikito Harakiri wrote:
> >
> > The key idea is that you treat the expression with unit symbols, for
> > example
> > [...]
> > Now, when applied to the database, how should we store 20 feet? User
> > defined types provide us some (quite unsophisticated) solution. But do
> > we really have to program a class every time we want to do trivial
> > conversions?
>
> I believe that C++, for example, has everything you need to
> be able to do this sort of thing in the type system. I am
> not aware, however, of any body of people finding it to be
> worth the effort.

Again, type system has little to offer.

Adding

5 * lbs + 5 * kg

is perfectly legal, although depends upon "lbs" defintion. If

lbs = 0.4 * kg

then we simply substitute. Then we apply distributive law. How about adding velocity to distance? Why not:

5 * m / c^2 + 20 * m

We can apply a distributive law again

(5 / c^2 + 20) * m

but we fail to isolate unit symbols in a separate factor. Received on Tue Jul 12 2005 - 23:34:38 CEST

Original text of this message