[Zope-dev] Referencial Integrity in ZCatalogs

Santi Camps scamps at earcon.com
Mon Aug 2 07:46:55 EDT 2004


Hi all,

I've been developing database oriented applications for about 10 years, 
using zope with Relation DDBB for one year and a half, and just one year 
using Zope with ZODB in my applications.   At this point, I can see a 
lot of advantatges of use ZODB with Zope, but there are some points 
where the relational model was more useful to me. 
In fact, the main problem in my applications are relationships.   In a 
relational world, you can specify relations using foreign keys, and also 
say what action should be done on delete or on update (no action, set 
null, restrict, cascade, set default).   This is very useful developing 
business oriented applications. 
Using ZODB some of these relations can be done using containment:   If A 
contains B, this is the same of having a relation "1->N on delete cascade"
Another case is to use a Relation Manager.   I've implemented and object 
Relation that is deleted when some of the two related objects are (using 
manage_beforeDelete).  This is the same that a relation "M -> N on 
delete cascade"
The third case I've been implemented, and the one giving me more 
problems, is to have a property referencing another object (path or 
UID).  If the referenced object is dropped, the referer has problems

I work a lot with ZCatalogs, using one catalog for each meta_type of 
objects, so for me catalogs are the most similar thing to a "Table".   
I'm thinking that could be very useful to implement some basic 
referencial integrity in ZCatalogs.   Just being able to define primary 
keys and some simple types of foreign keys we will have on Zope the best 
of two worlds.   Seeing code of ZCatalog product it seems not to be very 
difficult to implement, adding some validations on catalog_object and 
uncatalog_object methods.   Of course, all these should be optional.   I 
no Primary Keys neither Foreign Keys are defined, catalogs should work 
exactly like until now.

What do you think about this ?  If nobody convince me that this is a 
stupid work, I will try to implement it.   In this case, what's the 
better way to provide the code ?  A patch for ZCatalog ?  Or a new 
Product IntegrityZCatalog inheriting from ZCatalog ?

Thanks

Santi Camps



More information about the Zope-Dev mailing list