pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tim Landscheidt <tim@tim-landscheidt.de>
To: pgsql-sql@postgresql.org
Subject: Re: enforcing constraints across multiple tables
Date: Fri, 25 Jun 2010 19:01:14 +0000
Message-ID: <m3iq57gcn9.fsf@passepartout.tim-landscheidt.de> (raw)
References: <AANLkTilvEsBFcRoNvgLi_2h-axAZuSrgb-IlL6tuIk4t@mail.gmail.com>

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




view thread (3+ messages)  latest in thread

Message-ID: <m3iq57gcn9.fsf@passepartout.tim-landscheidt.de>
Permalink:  ../m3iq57gcn9.fsf@passepartout.tim-landscheidt.de/
Also on:    postgresql.org/message-id/m3iq57gcn9.fsf@passepartout.tim-landscheidt.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tim@tim-landscheidt.de
  Subject: Re: enforcing constraints across multiple tables
  In-Reply-To: <m3iq57gcn9.fsf@passepartout.tim-landscheidt.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox