Re: enforcing constraints across multiple tables

From: Tim Landscheidt <tim(at)tim-landscheidt(dot)de>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: enforcing constraints across multiple tables
Date: 2010-06-25 19:01:14
Message-ID: m3iq57gcn9.fsf@passepartout.tim-landscheidt.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Andrew Geery <andrew(dot)geery(at)gmail(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Ireneusz Pluta 2010-06-25 19:33:55 Re: Average of Array?
Previous Message Adrian Klaver 2010-06-25 18:37:25 Re: COPY command and required file permissions