Re: Multi-table CHECK constraint

From: "Richard Broersma" <richard(dot)broersma(at)gmail(dot)com>
To: "Jason Long" <mailing(dot)list(at)supernovasoftware(dot)com>
Cc: "PostgreSQL General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Multi-table CHECK constraint
Date: 2008-12-11 00:17:58
Message-ID: 396486430812101617p27c2f5f0te25cbc6fe8a6c31@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Dec 10, 2008 at 3:58 PM, Jason Long
<mailing(dot)list(at)supernovasoftware(dot)com> wrote:

> I need to add some complex constraints at the DB.
> These will involve several tables.
> What is the best approach for this?

Well ANSI-SQL provides the CREATE ASSERTION for this purpose.
However, PostgreSQL doesn't support this feature. It can be mimiced
by using the PostgreSQL CONSTRAINT TRIGGER extenstion. IIRC, it works
very much like an ordinary trigger except that you must raise an error
when an DML attempt possibly violates your condition.

> Can someone point me to an example of doing something like this?

http://www.postgresql.org/docs/8.3/interactive/sql-createconstraint.html
http://www.postgresql.org/docs/8.3/interactive/triggers.html

I hope this helps.

--
Regards,
Richard Broersma Jr.

Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jason Long 2008-12-11 00:23:35 Re: Multi-table CHECK constraint
Previous Message David Wall 2008-12-11 00:05:56 Re: Data Replication