1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Recommended pattern for relating data between modules

Recommended pattern for relating data between modules

2 posts, 0 answered
  1. Schneider
    Schneider avatar
    29 posts
    Registered:
    02 Nov 2008
    13 Nov 2008
    Link to this post
    Hi,

    We are building two plugin modules based upon generic_content.

    Each piece of content in module A needs to relate to a piece of content in module B.

    What is the best pattern for doing this?

    For example, should be store the GUID of content B inside a meta field in content A?

    Should we store the title of content B inside A in case content B gets deleted?

    How should we ensure data integrity between A and B e.g. prevent people delete B when A references it?

    I am presuming this is already being done when an image from the Library module is referenced from Generic_Cotent. How does that work?

    Thanks,
    Jack
  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    18 Nov 2008
    Link to this post
    Hi Schneider,

    We suggest you storing the reference of A to B with a Guid in a metafield, as you actually suggested. Sitefinity does not handle data integrity checks automatically so you would have to take care of this. When you delete content item in module B, you could check with our APIs if this content is referenced by a an item from module A. This could be done by iterating through all items in A and look for such with a given GUID record in given metafield.

    The Libraries module works in a similar principle - every library item has a ParentID (which is a GUID), which is the ID of the Library holding this item.

    I hope you find this helpful.

    Greetings,
    Georgi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
2 posts, 0 answered