Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 2878763F7A0; Mon, 20 Apr 2009 08:35:05 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 95871-01-6; Mon, 20 Apr 2009 08:34:54 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-gx0-f220.google.com (mail-gx0-f220.google.com [209.85.217.220]) by mail.postgresql.org (Postfix) with ESMTP id C1D3A6386A3; Mon, 20 Apr 2009 08:13:17 -0300 (ADT) Received: by gxk20 with SMTP id 20so4762714gxk.19 for ; Mon, 20 Apr 2009 04:13:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type; bh=SwZVWmEdYD/5qygqK4FFa8H1EAVD5jNUUFPZW/TxipM=; b=KTGNBgtPgPjgrI8tyex0ymNzFtFWdCg/b5mD/M5FlqXWOMN04lryJDtHJdjCoS9Qz9 bTf2HLClRn+3to+gUM8JcS3oqLZfkmrEEYl67J36HQbT6YkZG0+4ZTZx5KbERb1e1MlQ hgXeEsjDBSYBdhQNMS+feUPg95ikJ/HatFVxo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=BysIJFpZgPc1dKsSkL29QnnMPRFJjJZplwzzI6FF6AQV6KzESfBccRRxGvr7bxrMYK ZUQr67xcUjnXrhUD6youH3wZoJhzfyPKELUqna8tA6eqzP68veHjfFWEx+WdVoelh+KR dxlGsBXDnXg116GFUtUb9NKwg0SG/JxPSssOI= MIME-Version: 1.0 Received: by 10.231.35.66 with SMTP id o2mr3271251ibd.2.1240225996086; Mon, 20 Apr 2009 04:13:16 -0700 (PDT) In-Reply-To: <20090419235619.GB10700@fetter.org> References: <41534c40904191403m2eeabc27tc4bc6ce206c87464@mail.gmail.com> <20090419235619.GB10700@fetter.org> Date: Mon, 20 Apr 2009 08:13:15 -0300 X-Google-Sender-Auth: 647a0b71abaf0cd4 Message-ID: <41534c40904200413y60b140a4wf4305c36efd214c0@mail.gmail.com> Subject: Re: [DOCS] Postgresql 8.3X supports Arrays of Composite Types? From: Robson Fidalgo To: David Fetter Cc: pgsql-docs@postgresql.org, pgsql-general@postgresql.org Content-Type: multipart/alternative; boundary=000325573806f01ebc0467fa9d1e 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: 200904/779 X-Sequence-Number: 146735 --000325573806f01ebc0467fa9d1e Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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 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 http://fetter.org/ > Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter > Skype: davidfetter XMPP: david.fetter@gmail.com > > Remember to vote! > Consider donating to Postgres: http://www.postgresql.org/about/donate > > -- > Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-docs > --000325573806f01ebc0467fa9d1e Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

Hi David,

=A0

Thanks for your help, but I want a relational-object solution. The s= olution presented by Tom Lane (Thanks Tom!!!!) runs very well and it is a r= elational-object implementation (I suggest put a similar example in postgre= sql 8.3X documentation).

=A0

Cheers,

Robson.



--000325573806f01ebc0467fa9d1e--