Mixing Heterogeneity and Relationships

I want to use heterogeneity and relationships in my application to create different views on my data.

Lets say I have the following objects:

  • Folders
  • Items

and the following rules apply:

  • A Folder can contain (sub)folders or items.
  • An Item must be in a Folder

Is there any advice on getting the best performance out of my application?
At the moment I’m modeling the data graph so that I can create the UI views that I want. I want to be able to:

  • View all Folders and Items in an Overview
  • View all Folders and Items in a Tree

This has led to the following model graph

However, I’m concerned that when I load the Tree that the performance will suffer as:

  1. I load the Folders at root level
  2. I load the linked Folders and Items
  3. To load the linked Folders and Items I need to search the two subtypes, Folder_DM and Item_DM
  4. Item_DM is a subtype of Folder_DM so could be loaded / searched twice

Is this all taken care of for me through Heterogeneity Resolution in Data Services or do I need to change my modeling?

Hi @malcolm-silver-ice, from Heterogeneity perspective, if FoldersAndItems_DM is supertype of Folder_DM and Item_DM, then I think the resolution is cover this case completely. Hence the relationship here might be self-referenced relationship, in QueryAPI we provide maxDepth parameter when querying nested relationship structure like this then the performance is guaranteed. I think this case has a similar example in A12 showcase please have a look at this <INTERNAL_LINK>

Thanks @loc-fleet-crest,

So any performance issue is more likely linked to the unlimited depth of the self-referencing relationship. Right?

Hello @loc-fleet-crest,

could you please answer @malcolm-silver-ice additional question in his comment?

All the best
your Discourse Moderation Team

yes, it is. The deeper nested links the more impacted performance, that’s why we introduce maxDepth parameter, to prevent unlimited depth.