[ZODB-Dev] Referential integrity

Patrick K. O'Brien pobrien@orbtech.com
Fri, 1 Mar 2002 09:53:04 -0600


In case you look at my Bulldozer project, I just want to point out that I
haven't yet solved this problem. But this is the direction in which I am
heading and I fully intend to have the kind of referential integrity
constraints you (and I) are used to in an RDBMS.

---
Patrick K. O'Brien
Orbtech

> -----Original Message-----
> From: zodb-dev-admin@zope.org [mailto:zodb-dev-admin@zope.org]On Behalf
> Of Arnaud Bienvenu
> Sent: Friday, March 01, 2002 9:40 AM
> To: Jim Fulton
> Cc: zodb-dev@zope.org
> Subject: Re: [ZODB-Dev] Referential integrity
>
>
> On Fri, Mar 01, 2002 at 09:47:37AM -0500, Jim Fulton wrote:
> > What list? There is no way to explicitly remove
> > an object from the database.  An object will be removed
> > from the database when it is no longer referenced.
>
> I understand that, but I want to set up constraints in my model,
> like people
> do with relational databases using foreign keys.
>
> Here is an example : imagine we have two classes : Person and
> Country. On the one hand, we have a pool of today's world countries, with
> their name and other attributes. This pool may be a list, a
> dictionnary, or
> any sequence you want. On the other hand, each Person instance
> refers to one
> Country instance that is part of the pool.
>
> Now imagine some country disappears : the person in charge of maintaining
> the list of countries up to date will remove it from the pool. I
> would like
> something to happen for every Person instance that refers to this country,
> because I don't want them to refer to some country that is not in the
> official list.
>
> In PostgreSQL terms :
> CREATE TABLE person (id INT4 PRIMARY KEY, lastname TEXT,
> country INT4 REFERENCES countries);
> CREATE TABLE countries (id INT4 PRIMARY KEY, name TEXT);
>
> (here I can't remove a country if it is referenced by a person)
>
> My question is : what is the best way to get this behaviour using ZODB (or
> maybe another OODB)
>
> Thanks to Steve, Greg and Patrick for their very interesting suggestions.
> --
> Arnaud Bienvenu
> http://www.makina-corpus.org/
>
> _______________________________________________
> For more information about ZODB, see the ZODB Wiki:
> http://www.zope.org/Wikis/ZODB/
>
> ZODB-Dev mailing list  -  ZODB-Dev@zope.org
> http://lists.zope.org/mailman/listinfo/zodb-dev