Search Postgresql Archives

Re: Extended unit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>   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.

Attachment: pgplhCrYdLtYJ.pgp
Description: PGP signature


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux