multi-row check constraints?

Поиск
Список
Период
Сортировка
От Angva
Тема multi-row check constraints?
Дата
Msg-id 1174422088.324548.101390@n59g2000hsh.googlegroups.com
обсуждение исходный текст
Ответы Re: multi-row check constraints?  (Jeff Davis <pgsql@j-davis.com>)
Re: multi-row check constraints?  ("Greg Sabino Mullane" <greg@turnstep.com>)
Список pgsql-general
Dear Postgres fans,

Hi, I was wondering what is the best way to achieve a multi-row check
constraint. For example, you have a table with two columns: ID and
percent, no primary key. The goal is to enforce that all values of
percent, per ID, add up to exactly 100%. I come from an Oracle
background, and what you would probably do on Oracle is create a
materialized view with the sum(percent) grouped by ID, then put a
constraint on the sum column. This problem is also solvable using
triggers, but it's messy and imposes a lot of serialization. Not to
mention easy to get wrong.

So, I've come across this problem in Postgres and was hoping someone
could steer me in the right direction.

Thank you,
Mark


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

Предыдущее
От: "Matthew.Pettis@gmail.com"
Дата:
Сообщение: Using PostgreSQL to archive personal email
Следующее
От: Benjamin Arai
Дата:
Сообщение: multi terabyte fulltext searching