pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Elphick <olly@lfix.co.uk>
To: BOUCHPAN-LERUST-JUERY Lionel <bouchpan@ie2.u-psud.fr>
Cc: pgsql-sql@postgresql.org
Subject: Re: General ISA and Foreign Key
Date: Mon, 07 May 2001 22:05:18 +0100
Message-ID: <200105072106.f47L5ciW014707@linda.lfix.co.uk> (raw)
In-Reply-To: <bouchpan@ie2.u-psud.fr> <20010507204632.A24888@pc48.ie2.u-psud.fr>

BOUCHPAN-LERUST-JUERY Lionel wrote:
  >In SQL I have the following tables
  >
  >CREATE TABLE film(
  >VisaExploitation INTEGER NOT NULL,
  >DureeTournage INTEGER NOT NULL,
  >Titre VARCHAR( 50 ),
  >
  >PRIMARY KEY ( VisaExploitation ) );
  >CREATE TABLE filmHistorique(
  >NbCostume INTEGER
  >) INHERITS ( film );
  >
  >create table filmDocumentaire(
  > ) INHERITS ( film );
  >
  >I have a weak entity:
  >
  >CREATE TABLE copie(
  >NumCopie INTEGER NOT NULL,
  >VisaExploitation INTEGER NOT NULL,
  >PRIMARY KEY( VisaExploitation, NumCopie ),
  >FOREIGN KEY( VisaExploitation ) REFERENCES film ON DELETE CASCADE );
  >
  >The problem is I have to be able to have the constraint on 
  >both 2 and 3 and I can't figure how to implement this.

You can't do this at present, because there is no support for a foreign 
key constraint on an inheritance hierarchy (it is a major defect with the
current implementation of inheritance).  

Although inheritance is conceptually correct, the lack of implementation
suggests an alternative course:

"film" should contain a row for every film and "filmHistorique" and
"filmDocumentaire" should have foreign key constraints on "film".  You
could maintain the contents of "film" by triggers on the other two tables.


-- 
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47  6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "Dearly beloved, avenge not yourselves, but rather give
      place unto wrath. For it is written, Vengeance is 
      mine; I will repay, saith the Lord. Therefore if thine
      enemy hunger, feed him; if he thirst, give him drink;
      for in so doing thou shalt heap coals of fire on his 
      head. Be not overcome of evil, but overcome evil with 
      good."      Romans 12:19-21 





view thread (3+ messages)  latest in thread

Message-ID: <200105072106.f47L5ciW014707@linda.lfix.co.uk>
Permalink:  ../200105072106.f47L5ciW014707@linda.lfix.co.uk/
Also on:    postgresql.org/message-id/200105072106.f47L5ciW014707@linda.lfix.co.uk

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: olly@lfix.co.uk, bouchpan@ie2.u-psud.fr
  Subject: Re: General ISA and Foreign Key
  In-Reply-To: <200105072106.f47L5ciW014707@linda.lfix.co.uk>
  References: <200105072106.f47L5ciW014707@linda.lfix.co.uk>

* 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