Skip Navigation

[Resolved] Migrating tables with many to many relationship with intermediary

This support ticket is created 3 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

This topic contains 1 reply, has 2 voices.

Last updated by Jamal 3 years, 10 months ago.

Assisted by: Jamal.

Author
Posts
#1958983
Capture2.PNG
Capture3.PNG
Capture1.PNG

I used the article below to help me plan for data migration:

https://toolset.com/course-lesson/many-to-many-post-relationships/

I applied my situation to the example in the article resulting in the below:
https://toolset.com/wp-content/uploads/tmp/Capture1.png

“Resource” can be one of three types, Lesson Plan, Learning Activity, or Classroom Resource. All three are set up with a similar relationship structure, so I’ll use Lesson Plan as my example.

One Lesson Plan can have many standards and one standard can be connected to many lesson plans. This is how the many-many relationship structure looks. lp2s acts as the intermediary.
https://toolset.com/wp-content/uploads/tmp/Capture3_1.png

Shown below, the query results in five records. The planid and lp_id match, but the standard id (tblstandards ID) is different for every record since each one points to a different standard.
https://toolset.com/wp-content/uploads/tmp/Capture2_2.png

Go to hidden link to see the actual output. Notice that there are five standards related to this lesson plan, matching the query output above.

So, I know how to do the following:

Create Custom Post types “Standards” and “Lesson Plans.”
Create custom fields for each post type.
Apply one-one or one-many relationships on import using WPAllImport Pro

Here is where my understanding of repeatable field groups vs Many-Many Relationships with Intermediary gets murky.

Could I combine all the standard id’s related to a Lesson Plan into a repeatable field group in the Lesson Plans custom post type, then do a one-many, Lesson Plans >> Standards relationship? OR, should I create an intermediary custom post type and import all intermediary data from my database that links Lesson Plans to related Standards in a Many-Many relationship?

I need to be able to see all Standards related to a Lesson Plan and all Lesson Plans related to a Standard. Thanks!

#1960083

Hello and thank you for contacting the Toolset support.

Please check the last section of this article, it explains how to build the CSV file in order to import many-to-many relationship. The relationship needs to be created before the import. The trick is to use one line for each link between the posts.
https://toolset.com/course-lesson/import-posts-from-csv-with-relationships-using-wp-all-import/#example-3-many-to-many-relationships