Re: [SQL] Rules, triggers, ??? - What is the best way to enforce data-valid ation tests??

From: wieck(at)debis(dot)com (Jan Wieck)
To: Greg Youngblood <YoungblG(at)houstoncellular(dot)com>
Cc: "'PostgreSQL SQL List'" <pgsql-sql(at)postgreSQL(dot)org>
Subject: Re: [SQL] Rules, triggers, ??? - What is the best way to enforce data-valid ation tests??
Date: 2000-01-27 17:26:31
Message-ID: m12Dsgh-0003kGC@orion.SAPserv.Hamburg.dsh.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> I am in the process of creating a large relational database. One of the key
> things I need to include in this database is a system to maintain data
> integrity across multiple tables.
>
> here's an example:
>
> [...]
>
> In the past I've tried triggers and rules and never did get them to work to
> my satisfaction. Either they would work for some tasks, but I couldn't adapt
> them to work in more complicated tables, or there were syntax problems and I
> never got them to work at all. If anyone can help, and provide some
> examples, i would greatly appreciate it.
>
> I currently have postgres 6.5.0 on the production server, and 6.5.1 or 6.5.2
> on my development boxes.

Version 7.0 will have support for FOREIGN KEY syntax, that's
what you're looking for.

I'm not sure if ALTER TABLE ... ADD CONSTRAINT will be
implemented, but at least you can define all the dependencies
during CREATE TABLE. The support not only includes the checks
about key existance as in your example. You can also specify
how the DB should behave if a referenced key from the primary
table is deleted or updated (for example let references
automatically follow, do cascaded deletes or simply reject
the modification as long as the PK is referenced).

Get a snapshot of the current development sources from our
CVS server using anon-CVS. Most of the functionality is
already there.

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#========================================= wieck(at)debis(dot)com (Jan Wieck) #

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Jan Wieck 2000-01-27 17:27:48 Re: [SQL] foreign key implementation
Previous Message uihtot 2000-01-27 17:18:34 18 yr. old blonde 5963