constraint/rule/trigger - insert into table X where not in table Y

Поиск
Список
Период
Сортировка
От David Kerr
Тема constraint/rule/trigger - insert into table X where not in table Y
Дата
Msg-id 20100714161343.GC8493@mr-paradox.net
обсуждение исходный текст
Ответы Re: constraint/rule/trigger - insert into table X where not in table Y  (Alban Hertroys <dalroi@solfertje.student.utwente.nl>)
Список pgsql-general
Howdy,

I'm trying to think of the best way to handle this situation.

I've got 2 tables,  X and Y

Table X has a field foo varchar(20)
Table Y has a field bar varchar(20)

I want to enforce, that if table X.foo = 'dave' then you can't insert (or update) Y.bar = 'dave'

I know this is ideally done in the app, but in the interest of time to market i'm looking into
a simple DB solution.

I know i can do this with a trigger, but was wondering if there was a better way, like using
a constraint or a rule (seems like that would be pretty slick - but i can't wrap my head
around how to make it work)

Thanks

Dave

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

Предыдущее
От: Tim Landscheidt
Дата:
Сообщение: Re: Postgresql 8.4, XPath and name() function
Следующее
От: David Fetter
Дата:
Сообщение: Re: Need help doing a CSV import