public inbox for [email protected]
help / color / mirror / Atom feedFrom: David Fetter <[email protected]>
To: Robson Fidalgo <[email protected]>
Cc: [email protected]
Cc: [email protected]
Subject: Re: [GENERAL] Postgresql 8.3X supports Arrays of Composite Types?
Date: Sun, 19 Apr 2009 16:56:19 -0700
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
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 <[email protected]> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: [email protected]
Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate
view thread (8+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: [GENERAL] Postgresql 8.3X supports Arrays of Composite Types?
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox