Re: Extended unit - Mailing list pgsql-general

From Pailloncy Jean-Gerard
Subject Re: Extended unit
Date
Msg-id 24C2C6B8-6EE4-11D9-8B82-000A95DE2550@rilk.com
Whole thread Raw
In response to Re: Extended unit  (Roman Neuhauser <neuhauser@chello.cz>)
List pgsql-general
>     Is CREATE TYPE what you're looking for?
>     http://www.postgresql.org/docs/8.0/static/sql-createtype.html
No. I'll try to give an exemple of what I want:

I suppose I have the following table
CREATE TABLE experiment (
    distance    DOUBLE,
    time    DOUBLE,
    speed DOUBLE
);

I can do the following query :
SELECT distance+time+speed FROM experiment;

This is a valid SQL query, but there is no physical meaning.


Now, I suppose I have "extended type". So the table is:
CREATE TABLE experiment (
    distance DOUBLE(m1),
    time DOUBLE(s1),
    speed DOUBLE(m1s-1),
);

distance is of type DOUBLE and of unit METER
time is of type DOUBLE and of unit SECOND
speed is of type DOUBLE and of unit METER/SECOND

SELECT distance+time+speed FROM experiment;
Would throw an error : "Incompatible unit M1, S1, M1S-1"

SELECT distance/time+speed FROM experiment;
would succeed (obviously).


It may be possible to mess with domain/type to achieve a draft.
But I pretty sure that we need extend the type system to achieve it
cleanly.

Cordialement,
Jean-Gérard Pailloncy


pgsql-general by date:

Previous
From: alejandro fernandez
Date:
Subject: Restaurando una base de datos
Next
From: tmp
Date:
Subject: Recursive queries