Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id A905C6338B8 for ; Sat, 6 Jun 2009 04:10:16 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 79805-07 for ; Sat, 6 Jun 2009 04:10:15 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-bw0-f211.google.com (mail-bw0-f211.google.com [209.85.218.211]) by mail.postgresql.org (Postfix) with ESMTP id D1144632E34 for ; Sat, 6 Jun 2009 04:10:14 -0300 (ADT) Received: by bwz7 with SMTP id 7so1938750bwz.19 for ; Sat, 06 Jun 2009 00:10:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=sv30pfZH9wfvYxDpdL5iQfCacrHF9VNirtNcgf/5L8A=; b=GDPU4d6LdPEWQzR9vaNkfnKIRIPKJBrRKyT1b4BlsIoR4l0NviWGVSCjqz4+jKAqLJ gJWxnv42CHGUEI7TrNpCPVWvJAwtDYeyNDU4wMLkPBCEYX736B7rAQO7t7it5FWW9tC9 00ZWbCMh3cnweQzC4NYkZwxsbSYhZgEWR1ilw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=IBsv0Jlwnjq7EeD5ykoewtyZFVKfG9CUlJq4394Tin3zXDO2XDq9inaY08YdMVC3lI pjILNQm31NWAgvim8lgm68UsYG4EdiMY/MMaXxO+r1/EYjzEuY5wy93lQmhwRgWB7kYX 42Zz5z8bUK06LwrWkk+IhgJfHBuENH8AzE/jE= MIME-Version: 1.0 Received: by 10.239.132.205 with SMTP id 13mr331356hbs.168.1244272212718; Sat, 06 Jun 2009 00:10:12 -0700 (PDT) In-Reply-To: <4A294A00.5020802@gmail.com> References: <5eca56860906050330w6171b327k95881b13c4dca466@mail.gmail.com> <4A294A00.5020802@gmail.com> Date: Sat, 6 Jun 2009 09:10:12 +0200 Message-ID: <5eca56860906060010y4177b88apcf587d62f7286b5d@mail.gmail.com> Subject: Re: Type inheritance From: Gianvito Pio To: pgsql-sql@postgresql.org Content-Type: multipart/alternative; boundary=001485f44bfe3e357c046ba8b3d6 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200906/26 X-Sequence-Number: 32631 --001485f44bfe3e357c046ba8b3d6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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 > 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@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql > --001485f44bfe3e357c046ba8b3d6 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Oh that was just an example...Let me make a real example:
I have a table "Sensors" (that=A0has to contain different se= nsor types)=A0with a=A0Value. That value doesn't have to be fixed, but = I want to define it in=A0a way that it changes its structure when the senso= r type changes. For example,=A0for Temperature sensor I would like to have= =A0just a=A0float number, but for the humidity I could need of absolute and= relative humidity (2=A0floats). I'd just like to know if I can say tha= t the VALUE is a composite type...that I have then to specialize in Temp Ty= pe=A0and Humidity type...using them in their particular case.
=A0
This procedure has a name...and it's the inheritance. As I underst= ood, 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@gmail.com>
I'm not sure how Temperature= and Humidity are related as types beyond "extends float". i.e. W= hat tuple definition could alternatively have a Temp or a Humidity value? = =A0(I do understand their physical relationship :) )=20




Gianvito Pio wrote:
Hi all,
I just want to ask yo= u 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 Humidi= ty and then define a table that has an attribute of Value type (that can ac= cept both specialized types).

Thanks


--
Sent via pgsql-sql mailing list (pgsql-sql@postgres= ql.org)
To make changes to your subscription:
http://www.postgres= ql.org/mailpref/pgsql-sql

--001485f44bfe3e357c046ba8b3d6--