Re: How to ensure data consistency?

From: Felix E. Klee <felix.klee_at_inka.de>
Date: Wed, 8 Sep 2004 00:05:14 +0200
Message-ID: <20040908000514.7cbd418c.felix.klee_at_inka.de>


On 7 Sep 2004 08:21:25 -0700 Tony Andrews wrote:
> > However, there still needs to be validation (with triggers?) that
> > the id's of the specified specialization are non null.
>
> Check constraints can be used for that:
>
> CHECK ((type = 'A' AND a_id IS NOT NULL) OR (type != 'A' AND a_id IS
> NULL))
Thanks. This looks like a very simple solution (no time to check it right now, though).

What I still need, however, is a way to avoid "orphaned" entries in the specialization tables. Using my proposed data model, it would be possible to add such entries without having an entry in the main table. But, an entry in the main table cannot be made without an appropriate entry in the corresponding specialization table (foreign key constraints!).

A solution for the latter problem, I guess, is to build a UI whose backend always creates rows for the specialization table *and* the main table.

Felix Received on Wed Sep 08 2004 - 00:05:14 CEST

Original text of this message