Re: foreign keys as arrays - Mailing list pgsql-general

From Tulio Oliveira
Subject Re: foreign keys as arrays
Date
Msg-id 3A4899C5.D031D892@marilia.com
Whole thread Raw
In response to "C" libpq-fe.h  (Tulio Oliveira <mestredosmagos@marilia.com>)
List pgsql-general
Alan Young wrote:
>
> Is there a way I can do something like the following?
>
> create table t1 (
> t1id serial,
> );
>
> create table t2 (
> t1id int[] references t1 (t1id)
> );
>
> I know this doesn't work because I get an error message when trying to
> insert into t2.
>
> I'd like to be able allow multiple references if possible.  Has anyone found
> a way to make this work?
>
> Also, how do I update an array field?
>
> For example, t2.t1id = '{1,2,3}' and I want to add 4 to make it t2.t1id =
> '{1,2,3,4}'.
>
> Thanks.
> Alan Young
> Programmer/Analyst
> IDIGlobal.com

You must create T1 this form:

CREATE TABLE t1 (
    t1id SERIAL PRIMARY KEY
);


--
======================================================
AKACIA TECNOLOGIA
Desenvolvimento de sistemas para Internet
www.akacia.com.br

pgsql-general by date:

Previous
From: teg@redhat.com (Trond Eivind Glomsrød)
Date:
Subject: Re: red hat/mysql fiasco
Next
From: Nelio Alves Pereira Filho
Date:
Subject: MySQL to PostgreSQL