CONSTRAINT REFERENCE betwen array to single - Mailing list pgsql-general

From gustavo halperin
Subject CONSTRAINT REFERENCE betwen array to single
Date
Msg-id 44E24768.2010503@gmail.com
Whole thread Raw
List pgsql-general
Hello

I have a table with an array of smallint that I want reference to a
column of smallint, see below:
/    database=# CREATE TABLE id_names ( id smallint CONSTRAINT the_id
PRIMARY KEY NOT NULL,
    database(# name text CONSTRAINT the_name UNIQUE ) WITH OIDS;
    NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"the_id" for table "id_names"
    NOTICE:  CREATE TABLE / UNIQUE will create implicit index "the_name"
for table "id_names"
    CREATE TABLE
    database=# CREATE TABLE constrain_id ( id smallint[] CONSTRAINT
the_id_constr REFERENCES id_names (id) ) WITH OIDS;
    ERROR:  foreign key constraint "the_id_constr" cannot be implemented
    DETAIL:  Key columns "id" and "id" are of incompatible types:
smallint[] and smallint./
I mean, each of the possibles values in constrain_id.id[i] must be in
id_names.id . There are any way to do it with CONSTRAINT ???

  Thank you very much,
           Gustavo


pgsql-general by date:

Previous
From: John Purser
Date:
Subject: Re: Changing the data directory Ubuntu
Next
From: "Harvey, Allan AC"
Date:
Subject: Re: plpgsql dynamic queries and optional arguments