cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Regular Visitor

Creating records for N:N relationships

Hello, 

 

I've created a Model Driven app, with 2 custom entities. 

 

Then I created a Many to Many relationship between these entities. I'm aware about the intersect entity that will be created to maintain this N:N relatioship, but I don't know how to create records (multiple one) for one of the entities. 

 

so my question is: How can I create multiple records for one of these entities?

 

Thanks in advance for your help! 

1 ACCEPTED SOLUTION

Accepted Solutions

This opinion may be somewhat controversial, so make of it what you will (I come from a SQL background and have limited experience with CDS so I will admit I may be missing something here).

N:N relationships, multi-value fields and so on are not standard relational concepts. I assume they have been implemented to make designing building databases easier for users who do not understand relational modelling (CDS being promoted as a 'low code' database platform). As such, use of these features mean you will likely hit issues when you want to do things like filter or add records.

If you model the relationship 'correctly' (i.e. two parent tables and a child table that takes as foreign keys the primary keys from each parent) then adding/removing records to the child table is the same as you add records to any other table and you do not need to worry about learning any additional commands and syntax such as 'Relate' / 'Unrelate' or hit other problems where these non-standard features are not fully supported.

View solution in original post

4 REPLIES 4
Super User II
Super User II

This is easily accomplished using a canvas app, or using Flow.

 

The MDA unified client interface (UCI) is less capable for doing bulk inserts into the system table, which tracks the relationships. As you've seen, this is very intuitive for relating from one record to others.

 

What is your logic for deciding which X record is associated to which Y record? We can then decide the best way to handle it.

Let's say the use case is the following:

 

I'm maintaining a software inventory for an organization with multiple sites. Each site is using a different version of the software. 

 

I want to keep one entry for the software, but the relationship location-software owns the version used in every site. 

 

The solution I found so far is to use a custom intersec entity, on which I can created the fields I need. 

 

I'm just wondering if there is a better solution. 

This opinion may be somewhat controversial, so make of it what you will (I come from a SQL background and have limited experience with CDS so I will admit I may be missing something here).

N:N relationships, multi-value fields and so on are not standard relational concepts. I assume they have been implemented to make designing building databases easier for users who do not understand relational modelling (CDS being promoted as a 'low code' database platform). As such, use of these features mean you will likely hit issues when you want to do things like filter or add records.

If you model the relationship 'correctly' (i.e. two parent tables and a child table that takes as foreign keys the primary keys from each parent) then adding/removing records to the child table is the same as you add records to any other table and you do not need to worry about learning any additional commands and syntax such as 'Relate' / 'Unrelate' or hit other problems where these non-standard features are not fully supported.

View solution in original post

Thank you Paul! I guess that's the way I'll be proceeding. In my entire model, I have probably only 3 N:N relationships, which will be easy to maintain through a custom relationship (intersect) entity, that will exactly use the keys as you've described. 

 

I'll just wait for the feedback from @GAM to see if he have the same opinion. 

 

You help is appreciated 😉 

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (7,064)