Re: Not In Foreign Key Constraint

Поиск
Список
Период
Сортировка
От David Johnston
Тема Re: Not In Foreign Key Constraint
Дата
Msg-id 1379547387639-5771546.post@n5.nabble.com
обсуждение исходный текст
Ответ на Not In Foreign Key Constraint  (Misa Simic <misa.simic@gmail.com>)
Ответы Re: Not In Foreign Key Constraint  (Misa Simic <misa.simic@gmail.com>)
Список pgsql-hackers
Misa Simic wrote
> I guess that rule can be achieved with triigers on TableA and TableC - but
> the same is true for FK (and FK constraint is more effective then trigger
> -
> that is why I wonder would it be useful/achievable to create that kind of
> constraint)
> 
> Thoughts, ideas?

You create a common "keys in use" table and only insert a record into the
main tables if you can successfully add the desired key to the shared keys
table ( as a unique value ).  Setup a normal FK to that table to help
enforce that valid records must exist on the keys table.  Not fool-proof but
you only need to worry about insertions - delete from the pk table to remove
the record from the main table and free up the key.

David J.




--
View this message in context:
http://postgresql.1045698.n5.nabble.com/Not-In-Foreign-Key-Constraint-tp5771056p5771546.html
Sent from the PostgreSQL - hackers mailing list archive at Nabble.com.



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Vik Fearing
Дата:
Сообщение: Re: record identical operator
Следующее
От: Jeff Janes
Дата:
Сообщение: Freezing without write I/O