From: | silly8888 <silly8888(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: error caused by FOREIGN KEY on composite type |
Date: | 2009-11-05 12:13:38 |
Message-ID: | 3c8f9f940911050413r57abdf5bh3f27b924e5eeec6b@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, Nov 4, 2009 at 11:23 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> silly8888 <silly8888(at)gmail(dot)com> writes:
>> create type mytype as (x integer, y integer);
>
>> create table foo(
>> a mytype primary key,
>> b integer
>> );
>
>> create table bar(
>> a mytype references foo
>> );
>
> While that probably ought to work, is there a really good reason that
> you're not doing this with a conventional two-column primary key and
> foreign key? The composite type is going to be exceedingly inefficient,
> not to mention not portable to other DBMSes.
>
> regards, tom lane
>
You are right, the two-column solution is probably better. The only
reason I posted here was to see if I hit a bug (and it seems that I
might have).
BTW the composite might offer some small benefits in this case, namely
when combined with user defined DOMAINs it can simplify CHECK
constraints a lot.
From | Date | Subject | |
---|---|---|---|
Next Message | Howard Cole | 2009-11-05 12:48:31 | Re: Postgres for mobile website? |
Previous Message | Zimm1 | 2009-11-05 10:21:18 | UPDATE over a db_link |