Many to Many Entity Set Up Question

Many to Many Entity Set Up Question

  

Hello All,

I'm working on my first project with OutSystems, and am looking for a baseline answer to probably a basic question. I have read through the documentation and watched the tutorials but still not sure the best way to accomplish something like this. I apologize in advance for the 'newbie' question but have been impressed by the responses in the forums so thought I would try.

Scenario:

I have 3 Criteria for every location.
- State
- County
- Jurisdiction

Each of those can be many to many. Examples: One Jurisdiction may be available in multiple counties. Each State, of course, has multiple Counties.


Proposed Behavior: Would like for a user to have narrowed down options within the application. Example: If I select State of Alabama, I only want to see Counties in Alabama, and then Jurisdictions within the selected County.

My initial thought was to set up a separate Entity for all 3. But then I'm struggling with how to combine this data. Should they be separate Entities or one? Any tips would be helpful.


Also, I will want to be able to Add a New State, County, and Jurisdiction within the UI itself. I'm not sure if that impacts the set up, but wanted to mention it just in case. 


Thank you!

Brittany

Hi Brittany,

You can do this by adding an extra entity "CountryJurisdiction" to create the relations between the separate entities.

See: https://www.outsystems.com/help/servicestudio/9.0/Using_Data/Many_to_Many_Relationships.htm

Regards,

Jasper 

Jasper Oudenaarden wrote:

Hi Brittany,

You can do this by adding an extra entity "CountryJurisdiction" to create the relations between the separate entities.

See: https://www.outsystems.com/help/servicestudio/9.0/Using_Data/Many_to_Many_Relationships.htm

Regards,

Jasper 

Thank you for the response. Would I need to do a StateCounty Entity and a CountyJurisdiction Entity? Or can the one entity house the IDs for all 3?

- Brittany


Brittany Craft wrote:

Jasper Oudenaarden wrote:

Hi Brittany,

You can do this by adding an extra entity "CountryJurisdiction" to create the relations between the separate entities.

See: https://www.outsystems.com/help/servicestudio/9.0/Using_Data/Many_to_Many_Relationships.htm

Regards,

Jasper 

Thank you for the response. Would I need to do a StateCounty Entity and a CountyJurisdiction Entity? Or can the one entity house the IDs for all 3?

- Brittany


I would always create separate entities for these because it's meant to be a linktable between 2 entities.

But can a State have multiple Countries? Else this is not necessary of course....

Regards,
Jasper


Solution

Hello Brittany

Personally, I don't see any problem in having a single many-to-many entity that holds the three IDs.
Haven seen this before and it works well.

Depends on how you will USE the data.

As it seems, every Jurisdiction IS in a County, that it IS in a State.

A single entity with the three reference IDs (FK) will enable you to easily find the data.
But you will have to be carefull, eventually, to group (when using aggregates) depending on what are you looking for.

While the usual path would be to separate everything (normalize), sometimes this is not really necessary (and makes things harder to deal with).

Cheers,
Eduardo Jauch

Solution

Thank you both for the tips. Does the below look accurate now? I believe based on the advice and documentation provided above, I can now use the 'JurisdictionManagement' Entity to hold/manage all the data. 

You're welcome....looks good and usefull (for now)!   

Hello Brittany,

Yes. This is what I saw before.
In the day, we have a detail page for each entity, with a detail that presented all the pairs of the others (what is very easy to find through this aggregate), and an accelerator to chose a pair and add at once.

The advantage was that you could create the connections on any one of the details...

Cheers,
Eduardo Jauch

Thank you both for your help! I will keep playing with it and see how it works. If needed I can try and split it back out. 

Appreciate it!