Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Thomas Dolberg 74 posts 95 karma points
    Feb 13, 2011 @ 21:07
    Thomas Dolberg
    0

    Creating a many to many relationship between nodes

    Hi

    I need to link a number of nodes and as far as I can tell, the relationship API does not support many to many relationships. 

    I am thinking about placing the relationships in a custom table, but I don't know, if there is a better way of doing it?

    thanks

    Thomas

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Feb 13, 2011 @ 21:17
    Hendy Racher
    0

    Hi Thomas,

    Can you give an example as to the data you'd like to associate ? The relationship API can be used to link many to many...

    Cheers,

    Hendy

  • Thomas Dolberg 74 posts 95 karma points
    Feb 13, 2011 @ 21:24
    Thomas Dolberg
    0

    Hi Hendy

    I have a website where a number of nodes share some basic data. So when I update the data on a node, I would like to update/sync the other nodes with the data. So I guess it would be sufficient to store a many-to-many relationship based on the nodeIds. When I then update a node, I can fetch the other nodes based on their Ids and then update the data on each node.

    But I don't know how to achieve this with the relationship API. As far as I can tell from the relationship API, it only supports relationship between two nodes, and I need relationships between X number of nodes.

    thanks

    Thomas

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Feb 13, 2011 @ 21:29
    Hendy Racher
    0

    Hi Thomas,

    if you use a Parent to Child RelationType and link A to B, and then A to C, it's possible to return B and C supplying the parameter A, ie. returning a collection of IDs linked to the ID of the node just updated, is this what you're after ?

    Cheers,

    Hendy

  • Thomas Dolberg 74 posts 95 karma points
    Feb 13, 2011 @ 21:39
    Thomas Dolberg
    0

    I would like to support the following scenarios:

    When I update node  A, I also update node B and node C

    When I update node B, I also update node A and node C

    When I update node C, I also update node A and node B

     

    So what your are suggesting is to create Parent to Child RelationTypes for A->B and A->C.

    Another set of Parent to Child RelationTypes for B->A and B->C.

    And yet another set of Parent to Child RelationTypes C->A and C->B ?

    Which I guess would be fine since my custom table would also create the following relationships:

    A->B

    A->C

    B->A

    B->C

    C->A

    C->B

     

    Cheers,

    Thomas

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Feb 13, 2011 @ 21:54
    Hendy Racher
    0

    Hi Thomas,

    How about using a single bidirectional RelationType and linking:

    A <---> B

    A <---> C

    B <---> C

    a query looking for B will return A and C

    HTH,

    Hendy

  • Thomas Dolberg 74 posts 95 karma points
    Feb 13, 2011 @ 22:16
    Thomas Dolberg
    0

    Hi Hendy

     

    that seems to be the best solution. Thanks!

    Do I need to install the Relation Types package first (btw I am on umb 4.6.1)?

     

    thanks

    Thomas

  • Thomas Dolberg 74 posts 95 karma points
    Feb 13, 2011 @ 22:25
    Thomas Dolberg
    0

    Hi Hendy

     

    I installed the RelationTypes package, but I cannot create any relation types (the create option is not there when I right click and the create-button is greyed out). Any suggestions?

     

    thanks

    Thomas

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Feb 13, 2011 @ 22:30
    Hendy Racher
    0

    Hi Thomas,

    You don't need to install the Relation Types package, (it works in 4.6.1) but it does offer a nice UI to be able to manage the rows in the umbracoRelationType table.

    Cheers,

    Hendy

  • Thomas Dolberg 74 posts 95 karma points
    Feb 13, 2011 @ 22:36
    Thomas Dolberg
    0

    Hi Hendy

     

    just recompiled and republished the site and now I can create the RelationTypes using the Relation Type package :-)

     

    Cheers

    Thomas

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Feb 13, 2011 @ 22:39
    Hendy Racher
    0

    Hi Thomas,

    I've noticed that too, but only occasionly which is odd - if you restart the app, the right click actions should then appear... would be good to solve this one...

    Cheers,

    Hendy

  • Thomas Dolberg 74 posts 95 karma points
    Feb 13, 2011 @ 22:51
    Thomas Dolberg
    0

    Hi Hendy

     

    It works :-)

     

    One last thing, is it possible to expose the relationships on a node in the backend? 

     

    thanks

    Thomas

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Feb 13, 2011 @ 22:55
    Hendy Racher
    0

    Hi Thomas, I started on that, the source in CodePlex has an additional tab that lists out the Relations for a particular Relation Type...

    HTH,

    Hendy

  • Thomas Dolberg 74 posts 95 karma points
    Feb 13, 2011 @ 23:19
    Thomas Dolberg
    0

    Hi Hendy

     

    thank you very much for your help. It is much appreciated.

     

    best regards

    Thomas

Please Sign in or register to post replies

Write your reply to:

Draft