Re: Foreign key constraint on sub-column of composite-type column

From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: David Lee <davidomundo(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Foreign key constraint on sub-column of composite-type column
Date: 2012-10-20 09:26:31
Message-ID: CA+U5nMKXerWz3UwbgtX7nJw3XACV1jXOgezbDP_6JhQwNd7RRQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 20 October 2012 06:57, David Lee <davidomundo(at)gmail(dot)com> wrote:

> I was trying to create foreign key constraints on a sub-column of a composite-type column, but couldn't find a way to do it. After asking around on IRC, it seems like this isn't supported in PostgreSQL.
>
> I wanted to do something like:
>
> create type profile as (account_id integer);
>
> create table users (profile profile);
>
> alter table users add constraint account_fk foreign key ((profile).account_id) references accounts;
>
> Would this be a viable feature request?

We're currently trying to add FKs for arrays. Other more complex
constraints make a lot of sense, just as exclusion constraints make
sense for single table constraints.

I think its worth logging so we know somebody actually wants this,
thanks for your input.

--
Simon Riggs http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2012-10-20 11:27:16 Re: [PATCH] explain tup_fetched/returned in monitoring-stats
Previous Message Kohei KaiGai 2012-10-20 07:24:35 Re: Move postgresql_fdw_validator into dblink