From: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
---|---|
To: | Pailloncy Jean-Gerard <jg(at)rilk(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Extended unit |
Date: | 2005-01-25 10:22:02 |
Message-ID: | 20050125102200.GF29308@svana.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tue, Jan 25, 2005 at 10:40:15AM +0100, Pailloncy Jean-Gerard wrote:
> Hi,
>
> My question is purely theoretical.
>
> I add use in my time in University some software that use "extended
> type".
> For each variable, we define the mandatory "classic type" as integer,
> float, double array of.
> And we define an optional "extended type" as the unit in the MKSA
> system (Meter, Kilogram, Second, Ampere) or any other unit we would
> have previously define (eg. Currency).
>
> This "extended type" was wonderful, because there was warning/error if
> "extend type" does not match in any computation: you can not add apple
> to orange.
I think it's a wonderful idea. You could use a similar mechanism to
implement:
- Currencies (so you can't add dollars to pounds)
- Timezone aware timestamps (so a time in Australia looks differet from
a time in Europe)
Probably much more.
> I would appreciate to have such system in PostgreSQL.
>
> Do you think, it is feasible ? unrealistic ?
> Any comment ?
I think it is definitly feasable. There's been discussion before. I
think the best way syntax-wise would be to extend the type system
generically to have subtypes. For example currency(gbp) and siunit(A).
This would simplify operators. You could create a simple add operator
that checked the subtype and complained if they didn't match. A
multiply operator for siunit might even return the appropriate derived
unit. An advanced add unit for currency might lookup an exchange rate
table.
However, I think this might be a tricky (but very worthwhile) project.
Maybe create a subtypes table with the columns (oid, supertypeid,
subtypename) and use the oid here to identify the subtype in storage.
To be complete it would need to change:
- The parser to idenify the new type definitions
- pg_dump to dump these types
- input/output functions for these types
- handle storage
But with a bit of work it could be a nice project.
Hope this helps,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.
From | Date | Subject | |
---|---|---|---|
Next Message | Terry Lee Tucker | 2005-01-25 11:19:44 | Re: disable trigger from transaction |
Previous Message | Pailloncy Jean-Gerard | 2005-01-25 09:40:15 | Extended unit |