Support Topics Documentation Slack YouTube Blog

Best way to import Many to Many relations between 2 tables "Companies" & "Categories"

Hi what’s the best way to do a csv import and to get Backendless to recognize the relationship as a Many to Many between “Companies” and “Categories”?

When I import a 3rd Join csv table will Backendless still import this 3rd join table or will it merge the many to many relations into both Companies and Categories tables with child object relations pointing to each other?

I’ve been using this article as a reference for the right csv file notation… Thanks

https://backendless.com/docs/rest/mgmt_import.html

Hello @William_Lee

When you import a table with a relations, it is necessary that all tables with which there are relations are also imported. This can be done by importing tables using an archive with csv files. If only 1 table is imported, then its relations will not be imported.

Regards,
Inna

Thanks but this wasn’t the answer I was looking for. Let me rephrase the question. I’m using MS Access to create 3 CSV files “company”, “category” & “company_category” for the many to many (MM) join.

However Backendless doesn’t need to use a 3rd join table between “company” and “category” to create a MM between them.

Do I just import all 3 tables and then manually add the following Object Relationship fields in “company” and “category” so they point to each other… and then somehow do an update query to copy the relationship data from the company_category MM table into these Object Relationship fields?

Or do I leave the 3rd MM table that I imported into Backendless?

Please explain what is the Best way to import tables into a MM relationship structure. Thanks.

Here’s another issue I’m having with the Import Relationship feature.

Hello @William_Lee

If I understood the essence of your question correctly, then the best way to import tables with relations using MS Access is to create test data, for example:

  1. Create a Parent table
  2. Create table Child
  3. Add a one-to-many relationship from Parent to Child
  4. Add multiple objects
  5. Make export - Console - Manage - Export
  6. Download export zip
  7. View the structure of csv files that are in the export zip file.
  8. Fill these files with your data or create your own csv files by analogy.
  9. Pack new csv files into zip
  10. Make an import.

Perhaps you want to achieve something else, correct me, and I will be happy to help you.