Search code examples
dotnetnuke2sxc

How to setup cross app entity relationships in 2sxc


I am new to 2sxc and am trying to build a relatively complex website using this module as base for developing the data modelling.

My site consists of lots of different Apps (in my view), like news, events, people, workgroups, etc.

My question is how should I address the relationships between entities:

  • on one hand, I know that I can create relationships if all entities belong to the same APP. But this does not promotes reusing existing apps and makes a single app more complex.
  • on the other hand, creating different apps, would promote reusability but has the additional complexity of cross app entity relations (if that is even possible?).

Are there any recomendations on how to tackle these issues and how to setup a cross app relation? Ex: WorkingGroups has a relation to people (one to many) Both Events and News share a relation to Categories (tags)


Solution

  • An App is a self-contained unit which can be exported/imported and should still work. So if items in an app relate to each other, that is how it's meant to be.

    If you create cross-app relationships (this is possible) then you lose integrity checks and similar.

    • So if you have complex issues tightly related it should be in one app.
    • If you have multiple apps which just use another app for additional lookup, that is possible

    EG: Let's say you have a people-app which describes the people, and you want to have other apps (like news) which mention a person - and the goal would be to be able to click on that person to get that profile or similar, this is how you would do it:

    1. Create the people app
    2. Create the news app
    3. In the people-app, make sure you have a unique ID for a person. I wouldn't use the data-id (a GUID) but rather a person code (like DM for Daniel Mettler) or similar.
    4. In the news-app, also create a person-id field. For simplicity, let's say it's just a text-dropdown. You could also create a data-dropdown which gets data from the other app, but that's advanced - so do this later. For now, make a dropdown and pre-fill the IDs of known people.

    Now you can create all the views etc. Make sure you add some null-checks and similar so the code doesn't break if it doesn't find the ID in the other app.