Re: Feature Proposal: Constant Values in Columns or Foreign Keys

From: Nils Gösche <cartan(at)cartan(dot)de>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Feature Proposal: Constant Values in Columns or Foreign Keys
Date: 2012-04-18 14:35:33
Message-ID: 00eb01cd1d70$8377edb0$8a67c910$@de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Vincent Veyron wrote:

> use a trigger on each of the derived tables, that cancels any insert if
> the same id already exists in the other table?

Yes, that would work.

> You don't say how your data gets inserted, but considering how
> complicated your preferred option looks, I have to ask why you can't
> use something as simple as :

[...]

> You'll have to build the queries according to the value of type, but
> this should give you the features you mention?

Sure, this is what I meant when I said that you could simply omit the type
field. However, if you still want the guarantee about not having two derived
rows for the same base row, you'll have to use a trigger function. The whole
point of the exercise is to avoid that trigger function and replace it with
a simple foreign key :-).

It's ok, maybe it's not worth the trouble.

Regards,
--
Nils Gösche
"Don't ask for whom the <CTRL-G> tolls."

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Eliot Gable 2012-04-18 16:47:43 Re: LOCK TABLE is not allowed in a non-volatile function
Previous Message Vincent Veyron 2012-04-18 14:27:20 Re: Feature Proposal: Constant Values in Columns or Foreign Keys