Re: [GENERAL] Postgresql 8.3X supports Arrays of Composite Types?

From: Robson Fidalgo <robson(dot)fidalgo(at)gmail(dot)com>
To: David Fetter <david(at)fetter(dot)org>
Cc: pgsql-docs(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org
Subject: Re: [GENERAL] Postgresql 8.3X supports Arrays of Composite Types?
Date: 2009-04-20 11:13:37
Message-ID: 41534c40904200413k19fba8d5y9ddffd61a775d573@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs pgsql-general

On Mon, Apr 20, 2009 at 8:13 AM, Robson Fidalgo <rdnf(at)cin(dot)ufpe(dot)br> wrote:

> Hi David,
>
>
>
> Thanks for your help, but I want a relational-object solution. The solution
> presented by Tom Lane (Thanks Tom!!!!) runs very well and it is a
> relational-object implementation (I suggest put a similar example in
> postgresql 8.3X documentation).
>
>
>
> Cheers,
>
> Robson.
>
> On Sun, Apr 19, 2009 at 8:56 PM, David Fetter <david(at)fetter(dot)org> wrote:
>
>> On Sun, Apr 19, 2009 at 06:03:26PM -0300, Robson Fidalgo wrote:
>> > Hello,
>> > I am using postgresql 8.3X and I created a table (see example below)
>> > that has an attribute that is an Array of a Composite Type (ROW).
>> > However, I do not know how can I insert a record in this table.
>>
>> You want a normalized table anyhow. If you want something
>> denormalized, use a view.
>>
>> > Example:
>> >
>> > CREATE table phone (
>> > cod varchar,
>> > num varchar);
>> >
>> > CREATE TABLE person (
>> > name varchar,
>> > telephone phone[]);
>>
>> This is better as:
>>
>> CREATE TABLE phone (
>> cod VARCHAR,
>> num VARCHAR,
>> PRIMARY KEY(cod, num)
>> );
>>
>> CREATE TABLE person (
>> name varchar,
>> PRIMARY KEY(name)
>> )
>>
>> CREATE TABLE person_phone (
>> name VARCHAR NOT NULL REFERENCES person(name),
>> cod VARCHAR,
>> num VARCHAR,
>> FOREIGN KEY(cod, num) REFERENCES phone(cod, num),
>> PRIMARY KEY(name, cod, num)
>> );
>>
>> Cheers,
>> David.
>> --
>> David Fetter <david(at)fetter(dot)org> http://fetter.org/
>> Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
>> Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com
>>
>> Remember to vote!
>> Consider donating to Postgres: http://www.postgresql.org/about/donate
>>
>> --
>> Sent via pgsql-docs mailing list (pgsql-docs(at)postgresql(dot)org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-docs
>>
>
>

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message Robson Fidalgo 2009-04-20 12:05:22 Does Postgresql 8.3X support Object/Class Methods and association between objects with REF?
Previous Message Robson Fidalgo 2009-04-20 11:13:15 Re: [DOCS] Postgresql 8.3X supports Arrays of Composite Types?

Browse pgsql-general by date

  From Date Subject
Next Message Robson Fidalgo 2009-04-20 12:05:22 Does Postgresql 8.3X support Object/Class Methods and association between objects with REF?
Previous Message Robson Fidalgo 2009-04-20 11:13:15 Re: [DOCS] Postgresql 8.3X supports Arrays of Composite Types?