cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted

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
Highlighted
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.

Highlighted

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. 

Highlighted

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

Highlighted

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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

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

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (10,338)