From: SZUCS Gábor <surrano@mailbox.hu>
To: pgsql-sql@postgresql.org
Subject: Re: array in a reference
Date: Wed, 14 May 2003 18:50:48 +0200
Message-ID: <017b01c31a38$f8cf1ec0$0a03a8c0@fejleszt2> (raw)
References: <000b01c314aa$70f58400$f100000a@IT001>
Ries,
----- Original Message -----
From: "Ries van Twisk" <ries@jongert.nl>
Sent: Wednesday, May 07, 2003 5:07 PM
> CREATE TABLE t0 {
> id SERIAL,
> value TEXT
> }
>
> CREATE TABLE t1 {
> id SERIAL,
> t0id INTEGER[] REFERENCES t0(id) -- <<<< Is this possible????
> }
I'd use a third table:
CREATE TABLE t1 (
id SERIAL
);
CREATE TABLE t1_refs_t0 (
t0id integer NOT NULL REFERENCES t0(id),
t1id integer NOT NULL REFERENCES t1(id)
-- Probably you'd like to add some unique constraint (if the orig. array
-- shouldn't contain equal values):
, UNIQUE (t1id, t0id)
);
And maybe a trigger (after insert/update on t1) to check that actually there
are rows in the refs table for the new t1.id, but I can't really find out
the correct syntax now :)
G.
--
while (!asleep()) sheep++;
---------------------------- cut here ------------------------------
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: pgsql-sql@postgresql.org
Cc: surrano@mailbox.hu
Subject: Re: array in a reference
In-Reply-To: <017b01c31a38$f8cf1ec0$0a03a8c0@fejleszt2>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox