pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
array in a reference
3+ messages / 3 participants
[nested] [flat]

* array in a reference
@ 2003-05-07 15:07 Ries van Twisk <ries@jongert.nl>
  2003-05-07 15:53 ` Re: array in a reference Stephan Szabo <sszabo@megazone23.bigpanda.com>
  2003-05-14 16:50 ` Re: array in a reference SZUCS Gábor <surrano@mailbox.hu>
  0 siblings, 2 replies; 3+ messages in thread

From: Ries van Twisk @ 2003-05-07 15:07 UTC (permalink / raw)
  To: pgsql-sql


Hey Guys,

I was just wondering if it is possible to use a REFERENCE in a array like
this below:

CREATE TABLE t0 {
	id	SERIAL,
	value	TEXT
}

CREATE TABLE t1 {
	id	SERIAL,
	t0id	INTEGER[] REFERENCES t0(id)     -- <<<< Is this possible????
}


regards,
Ries van Twisk




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: array in a reference
  2003-05-07 15:07 array in a reference Ries van Twisk <ries@jongert.nl>
@ 2003-05-07 15:53 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Stephan Szabo @ 2003-05-07 15:53 UTC (permalink / raw)
  To: Ries van Twisk <ries@jongert.nl>; +Cc: pgsql-sql

On Wed, 7 May 2003, Ries van Twisk wrote:

>
> Hey Guys,
>
> I was just wondering if it is possible to use a REFERENCE in a array like
> this below:
>
> CREATE TABLE t0 {
> 	id	SERIAL,
> 	value	TEXT
> }
>
> CREATE TABLE t1 {
> 	id	SERIAL,
> 	t0id	INTEGER[] REFERENCES t0(id)     -- <<<< Is this possible????

Not in this case, it's going to want to compare the entire array to the
id (and will probably fail saying that there's no = operator for _int4 and
int4).




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: array in a reference
  2003-05-07 15:07 array in a reference Ries van Twisk <ries@jongert.nl>
@ 2003-05-14 16:50 ` SZUCS Gábor <surrano@mailbox.hu>
  1 sibling, 0 replies; 3+ messages in thread

From: SZUCS Gábor @ 2003-05-14 16:50 UTC (permalink / raw)
  To: pgsql-sql

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 ------------------------------




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2003-05-14 16:50 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-05-07 15:07 array in a reference Ries van Twisk <ries@jongert.nl>
2003-05-07 15:53 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
2003-05-14 16:50 ` SZUCS Gábor <surrano@mailbox.hu>

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