Re: *Proper* solution for 1..* relationship?

From: Wolfgang Keller <feliphil(at)gmx(dot)net>
To: PostgreSQL List - Novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: *Proper* solution for 1..* relationship?
Date: 2013-04-29 16:43:04
Message-ID: 20130429184304.1862af6c16d511b2e73f8bb5@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

> If you want to enforce a 1 to N relationship, You can use a CONSTRAINT
> TRIGGER on the List table to ensure that there is at least one list
> item - if there isn't then raise an exception 'No List Items!!!'.
> You'd want to define the constraint as INITIALLY DEFERRED.
> http://www.postgresql.org/docs/9.2/interactive/sql-createtrigger.html
> http://www.postgresql.org/docs/9.2/interactive/sql-set-constraints.html
>
> A constraint trigger is the closest feature to an ASSERTION statement
> defined by the SQL standard.

Thanks, but the main issue for me is the precise definition of the
constraint to apply.

This issue should be as old as relational databases per se. I just can't
imagine no one has implemented a well-proven "standard" solution yet.

Sincerely,

Wolfgang

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Kevin Grittner 2013-04-29 20:05:43 Re: *Proper* solution for 1..* relationship?
Previous Message Stefan Kaltenbrunner 2013-04-27 19:02:44 Re: [NOVICE] How to Recover iPhone Contacts You Lost Somehow?