From: Alke <alke@iol.it>
To: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
To: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Array-fields and many-to-many relations
Date: Fri, 20 Aug 1999 23:28:05 +0200
Message-ID: <37BDC865.9BB15F3E@iol.it> (raw)
Hy all!
I want to make a many-to-many relation on my db, and I would like to use
an array-field of the external keys...
This is what I whoul like to create:
CREATE TABLE Groups(
IDGroup SERIAL, -- Primary key
...
);
CREATE TABLE Customers(
IDGroups INT4[], -- Multiple foreign keys
...
);
SELECT Customers.* FROM Customers WHERE IDSearchedGroup IN
Customers.IDGroups;
IDSearchedGruop is obviously a parameter.
Well, this query doesn't work because in the SELECT ... the operator
"IN" can work only on subselect, not on array... how can I check if an
element belongs to an array or not? Performance are not critical,
because I have few groups...
Yes, I know that the common way to make many-to-many relations is adding
a support table... but I don't like the conventional solution to this
problem... any ideas???
Paolo
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: alke@iol.it, pgsql-general@postgresql.org
Subject: Re: Array-fields and many-to-many relations
In-Reply-To: <37BDC865.9BB15F3E@iol.it>
References: <37BDC865.9BB15F3E@iol.it>
* 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