Re: Feature Proposal: Constant Values in Columns or Foreign Keys - Mailing list pgsql-general

From Nils Gösche
Subject Re: Feature Proposal: Constant Values in Columns or Foreign Keys
Date
Msg-id 00eb01cd1d70$8377edb0$8a67c910$@de
Whole thread Raw
In response to Re: Feature Proposal: Constant Values in Columns or Foreign Keys  (Vincent Veyron <vv.lists@wanadoo.fr>)
Responses Re: Feature Proposal: Constant Values in Columns or Foreign Keys  (Bartosz Dmytrak <bdmytrak@gmail.com>)
List 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."



pgsql-general by date:

Previous
From: Vincent Veyron
Date:
Subject: Re: Feature Proposal: Constant Values in Columns or Foreign Keys
Next
From: Eliot Gable
Date:
Subject: Re: LOCK TABLE is not allowed in a non-volatile function