Re: foreign keys as arrays

From: Tulio Oliveira <mestredosmagos(at)marilia(dot)com>
To: Alan Young <alany(at)qwest(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: foreign keys as arrays
Date: 2000-12-26 13:14:45
Message-ID: 3A4899C5.D031D892@marilia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Nelio Alves Pereira Filho 2000-12-26 13:43:26 MySQL to PostgreSQL
Previous Message Trond Eivind =?iso-8859-1?q?Glomsr=F8d?= 2000-12-26 12:43:11 Re: red hat/mysql fiasco