The use of arrays as foreign key

From: "Mourad EL HADJ MIMOUNE" <mimoune(at)ensma(dot)fr>
To: <pgsql-general(at)postgresql(dot)org>
Subject: The use of arrays as foreign key
Date: 2001-11-20 15:27:31
Message-ID: 006801c171d7$df496100$71a337c1@ensma.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,
I'am trying to use foreign key constraint on column of type int[] (
array ) without success.
Exemple:

Create table course (id serial, name varchar);
Create table student (id serial, name varchar, course int[3], Constraint
f_key Foreign key (course) references course (id));

plib_gene=# insert into course (name) values ('math');
INSERT 600730 1
plib_gene=# insert into course (name) values ('info');
INSERT 600731 1
plib_gene=# insert into course (name) values ('phys');
INSERT 600732 1
plib_gene=# insert into course (name) values ('chimie');
INSERT 600733 1
plib_gene=# insert into course (name) values ('sport');
INSERT 600734 1
plib_gene=# insert into student (name, course) values ('mourad', '{1,2,3}');
ERROR: Unable to identify an operator '=' for types 'int4' and '_int4'
You will have to retype this query using an explicit cast

I have installed a new operators on array types by using functions from the
contrib/array directory of postgresql source.
But I obtained the same error message.

Why we can't use OID as a foreign key?
What this the utility of OIDVECTOR?
Thanks for your help.
Mourad.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alexander Wallace 2001-11-20 15:28:30 Migrating from MSSql...
Previous Message Antonio Sergio de Mello e Souza 2001-11-20 15:22:05 Re: print out custom functions