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