[Zope3-Users] Expressing n:m relationship in ZODB
Hi, there was a discussion about the bad idea to simulate a relational database in ZODB using indexes and unique ids. So I wonder what's the correct way to express a n:m realtionship between objects. For example: I have projects and articles. An article might be relevant for multiple projects and a project might have multiple relevant articles. Could I simply give each object a list containing the related objects? Or is this kind of circular reference a problem? regards, Achim ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Expressing n:m relationship in ZODB
Am 11.07.2006 um 23:17 schrieb Achim Domma: Hi, there was a discussion about the bad idea to simulate a relational database in ZODB using indexes and unique ids. So I wonder what's the correct way to express a n:m realtionship between objects. For example: I have projects and articles. An article might be relevant for multiple projects and a project might have multiple relevant articles. Could I simply give each object a list containing the related objects? Or is this kind of circular reference a problem? As I gathered from discussions, one should first think to use direct object references for such relations. A module which might help in this is http://svn.zope.org/zc.extrinsicreference/ Would be interesting with what solution you will end. __Janko -- Janko Hauser email: [EMAIL PROTECTED] mobile: +49 1721 641552 PGP.sig Description: Signierter Teil der Nachricht ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Expressing n:m relationship in ZODB
Em Ter, 2006-07-11 às 23:17 +0200, Achim Domma escreveu: Hi, there was a discussion about the bad idea to simulate a relational database in ZODB using indexes and unique ids. So I wonder what's the correct way to express a n:m realtionship between objects. In usual Object Oriented modeling, an n:m relationship is usually modeled as a collection of relationship objects each one keeping one direct reference to each side of the relationship. Of course, using these systems that already try to model relationships helps you not to reinvent another wheel. -- Leonardo Rochael Almeida Enfold Systems http://www.enfoldsystems.com phone. +1.713.942.2377 Ext 215 fax. +1.832.201.8856 ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Expressing n:m relationship in ZODB
Leonardo Rochael Almeida wrote: In usual Object Oriented modeling, an n:m relationship is usually modeled as a collection of relationship objects each one keeping one direct reference to each side of the relationship. Of course, using these systems that already try to model relationships helps you not to reinvent another wheel. I think I understand. So if I would like to reinvent another wheel, just for the educatinal purpose, I should do it like this: If I have IArticle and IProject which should have a relationship, I would introduce IArticleProjectRelation which holds a reference to the related objects. These relation objects will be managed by an IArticleProjectRelationManager which has an interface like: relate(article,project) unrelate(article,project) get_related_articles(project) get_related_projects(article) In that case, IArticleProjectRelation would be an implementation detail of IArticleProjectRelationManager and I do not have to expose it at all. And in Zope 3 terms, I would implement the manager as a local utility. Right so far? If yes, I could add helper methods to IArticle and IProject which encapsulate the access of the utility to hide this detail from the user. Would you do that? Or has it some drawbacks which I don't see yet? thanks for your help, Achim ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Expressing n:m relationship in ZODB
What you describe sounds perfectly fine. You might want to consider exposing the actual IArticleProjectRelation object eventually if you decide to hang other attributes to it, say a 'start date'. Cheers, Leo Em Qua, 2006-07-12 às 00:40 +0200, Achim Domma escreveu: Leonardo Rochael Almeida wrote: In usual Object Oriented modeling, an n:m relationship is usually modeled as a collection of relationship objects each one keeping one direct reference to each side of the relationship. Of course, using these systems that already try to model relationships helps you not to reinvent another wheel. I think I understand. So if I would like to reinvent another wheel, just for the educatinal purpose, I should do it like this: If I have IArticle and IProject which should have a relationship, I would introduce IArticleProjectRelation which holds a reference to the related objects. These relation objects will be managed by an IArticleProjectRelationManager which has an interface like: relate(article,project) unrelate(article,project) get_related_articles(project) get_related_projects(article) In that case, IArticleProjectRelation would be an implementation detail of IArticleProjectRelationManager and I do not have to expose it at all. And in Zope 3 terms, I would implement the manager as a local utility. Right so far? If yes, I could add helper methods to IArticle and IProject which encapsulate the access of the utility to hide this detail from the user. Would you do that? Or has it some drawbacks which I don't see yet? thanks for your help, Achim ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users -- Leonardo Rochael Almeida Enfold Systems http://www.enfoldsystems.com phone. +1.713.942.2377 Ext 215 fax. +1.832.201.8856 ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users