Re: Type inheritance

From: Gianvito Pio <pio(dot)gianvito(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Type inheritance
Date: 2009-06-06 07:10:12
Message-ID: 5eca56860906060010y4177b88apcf587d62f7286b5d@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Oh that was just an example...Let me make a real example:
I have a table "Sensors" (that has to contain different sensor types) with
a Value. That value doesn't have to be fixed, but I want to define it in a
way that it changes its structure when the sensor type changes. For
example, for Temperature sensor I would like to have just a float number,
but for the humidity I could need of absolute and relative humidity
(2 floats). I'd just like to know if I can say that the VALUE is a composite
type...that I have then to specialize in Temp Type and Humidity type...using
them in their particular case.

This procedure has a name...and it's the inheritance. As I understood,
postgres allow me the table inheritance, but not the type inerithance. Here
is an example about how this works on Oracle:
http://www.oracle.com/technology/products/oracle9i/daily/jan29.html
2009/6/5 Rob Sargent <robjsargent(at)gmail(dot)com>

> I'm not sure how Temperature and Humidity are related as types beyond
> "extends float". i.e. What tuple definition could alternatively have a Temp
> or a Humidity value? (I do understand their physical relationship :) )
>
>
>
>
> Gianvito Pio wrote:
>
>> Hi all,
>> I just want to ask you if it's possible to define sub types in PostgreSQL
>> (Type inheritance). I found that table inheritance is possible...but I'd
>> like to do it on types.
>>
>> Example:
>> define a type Value and two subtypes Temperature and Humidity and then
>> define a table that has an attribute of Value type (that can accept both
>> specialized types).
>>
>> Thanks
>>
>
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Jasen Betts 2009-06-06 12:04:40 Re: Type inheritance
Previous Message Rob Sargent 2009-06-05 16:38:24 Re: Type inheritance