Re: Extended unit

Поиск
Список
Период
Сортировка
От Pailloncy Jean-Gerard
Тема Re: Extended unit
Дата
Msg-id 24C2C6B8-6EE4-11D9-8B82-000A95DE2550@rilk.com
обсуждение исходный текст
Ответ на Re: Extended unit  (Roman Neuhauser <neuhauser@chello.cz>)
Список 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 по дате отправления:

Предыдущее
От: alejandro fernandez
Дата:
Сообщение: Restaurando una base de datos
Следующее
От: tmp
Дата:
Сообщение: Recursive queries