Layout N-N relationshop

Hello :slight_smile:

I’m Yvan, new to Glide and my database is on GSheet.

I’m facing issues with managing N-N relationships in the layout and actions.

I have three tables: a company table SOCIETE, a shareholder table ACTIONNAIRE, and a table for N-N relationship ACTIONNAIRE2SOCIETE.

  1. I’d like to add a new company and select shareholders in it, indicating each shareholder’s percentage.
  2. When editing a company, I want to select shareholders in that company and update their shares.

I’m not sure how to use the Layout + Action to update multiple tables with N-N relationships.

What actions should I use to add a new company SOCIETE while updating the ACTIONNAIRE2SOCIETE shareholder list?

If it were me, I would get rid of the ACTIONNAIRE2SOCIETE table.

  • In the SOCIETE table, create a text column to hold a comma delimited list of shareholder IDs.
  • When adding or editing a company, add a choice component with multi-select enabled to select shareholders.
  • Write the selected shareholders to the new shareholder column.
  • Create a Split Text column to convert that comma delimited list into an array.
  • Finally build your relations between SOCIETE and ACTIONNAIRE using that Split Text array.
3 Likes

Thanks Jeff :pray:
Ah ok, so you simply won’t use intermediary tables to create the relationship but will store all of it in a new column? But how do I manage the share percentage of each shareholder? In which table can I store this information?

hmm, I think that Jeff may have missed that point…

Given that you need to store both the shareholder name and their share percentage, you might be better off with a link table after all.

The alternative could be to store the shareholder/share percentage as an array of JSON strings, but that would be much more difficult to manage.

So getting back to your original question…

  • In your SOCIETE table, create a multiple relation column that matches the SOCIETE name/ID with the same value in your link table.
  • When viewing a SOCIETE details screen, add a Collection component and use that multiple relation column as the source.
  • Enable editing on that collection, and that should allow you to edit the shareholder percentages.
2 Likes

Yeah I missed the part about shareholder percentages. I’m on vacation. Maybe I need to lay low for a bit.

2 Likes

Don’t worry, Jeff. Enjoy your vacation and throw away your laptop.

2 Likes