Can I habe multi table indices?

Started by Andreasabout 11 years ago2 messagesgeneral
Jump to latest
#1Andreas
maps.on@gmx.net

Hi,
can I habe multi table indices to ensure that certain IDs can only
appear in on relation?

Like

table_0(id int), table_1(id int), table_2(id int)
rel_1_to_0( id_1 int, id_0 int )
rel_2_to_0( id_2 int, id_0 int )

An id of table_0 should only exist either in rel_1_to_0 OR rel_2_to_0.

How can I do this?

regard
Andreas

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#2Laurenz Albe
laurenz.albe@cybertec.at
In reply to: Andreas (#1)
Re: Can I habe multi table indices?

Andreas wrote:

can I habe multi table indices to ensure that certain IDs can only
appear in on relation?

Like

table_0(id int), table_1(id int), table_2(id int)
rel_1_to_0( id_1 int, id_0 int )
rel_2_to_0( id_2 int, id_0 int )

An id of table_0 should only exist either in rel_1_to_0 OR rel_2_to_0.

You cannot have one index across several tables.

How can I do this?

Perhaps with a trigger that checks if the condition is satisfied.

Yours,
Laurenz Albe

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general