Re: enforcing constraints across multiple tables - Mailing list pgsql-sql

From Tim Landscheidt
Subject Re: enforcing constraints across multiple tables
Date
Msg-id m3iq57gcn9.fsf@passepartout.tim-landscheidt.de
Whole thread Raw
In response to enforcing constraints across multiple tables  (Andrew Geery <andrew.geery@gmail.com>)
List pgsql-sql
Andrew Geery <andrew.geery@gmail.com> wrote:

> [...]
> My questions are:
> (A) Is there a way to check (2) above using a constraint and not a trigger?
> (B) Is there an easier way to solve this problem?  Does the complicated
> nature of the solution make the design poor?
> (C) Should I not worry about this constraint at the DB level and just
> enforce it at the application level?
> [...]

I don't know about (A) and (B), but (C) is the solution of
choice in most complex cases. It's usually *much* easier to
enforce than with constraints and triggers (you have to do
it at application level anyway as well as you probably don't
want to pass PostgreSQL's errors directly to the user) and
your mind doesn't become twisted too much. I would schedule
regular tests on the data set though to ensure that you no-
tice problems early on.

Tim



pgsql-sql by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: COPY command and required file permissions
Next
From: Ireneusz Pluta
Date:
Subject: Re: Average of Array?