Skip Navigation

[Resolved] relations between tables of data, foreign keys and belongs_to

This support ticket is created 5 years, 4 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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: Asia/Kolkata (GMT+05:30)

This topic contains 4 replies, has 2 voices.

Last updated by Christophe Lepretre 5 years, 4 months ago.

Assisted by: Minesh.

Author
Posts
#1460565
album-schema.png

Hi There

Please have a look at the basic schema I've drawn.

I'm trying to develop a WP website that lists music album releases. Each album belongs to one band and belongs to one music label.

Each band and each music label have their own fields.

When I create a post for one album, I can't figure out how I can simply dropdown select the band and the music label. I don't want to retype all the data about the bands and labels every single time.

Eventually, I would like to access the band and music label attributes in the album view, like band.name, band.website, etc ...

I hope that was clear.

Please could could you just guide through the steps if this is possible ?

Thanks

#1461265

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I am not sure yet if you go through our post-relationship docs. Please check the following doc for basics of relationship:
=> https://toolset.com/documentation/post-relationships/

It looks like you need to connect many bands with many music labels. If this is true, you need many-to-many post-relationship:
=> https://toolset.com/documentation/post-relationships/how-to-set-up-post-relationships-using-toolset/#relationship-fields-in-many-to-many-relations

And here is the doc how you can display the related posts:
=> https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/

In addition to the above, if you would like to check how many-to-many post-relationship works, I suggest you should create test site using on our free test platform on discover-wp.com and use the reference site "Gyms and Trainers" where you will find the many-to-many post-relationship is created between post types Gyms and Personal Trainers. That example will be really helpful for you.
=> https://discover-wp.com/site-types/gyms-and-trainers/

I suggest you should go through the above docs as well as create your test site and play with that. Let me know if you need any help.

#1463645

Hi Minesh

Thanks a lot. So if I understand, Custom Post types are actually like the models of my database ? And if i create the custom post types / models, I can then create relationships and join data between tables ? So does that also mean that I need to create the custom post types even though I won't create posts for them (so only for data storage)?

I'm just trying to figure before starting the whole development and realize after a few days that I can't make happen what I need.

Many thanks for your help. I won't take any more of your time after that.

#1468579

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

So if I understand, Custom Post types are actually like the models of my database ? And if i create the custom post types / models, I can then create relationships and join data between tables?
==>
Custom Post Types will hold the posts and using the post-relationship you are allowed to connect post type X post with post type Y posts. You do not need to create any tables.

- you just need to create your post types and Add few posts to your post types:
=> https://toolset.com/documentation/user-guides/custom-content/create-a-custom-post-type/#basic-setup

- Then create your desired post-relationship:
=> https://toolset.com/documentation/post-relationships/

- Then you should use the post-relationship box to connect your posts:
=> https://toolset.com/documentation/post-relationships/how-to-set-up-post-relationships-using-toolset/#how-to-connect-related-posts

So does that also mean that I need to create the custom post types even though I won't create posts for them (so only for data storage)?
==>
I am not getting this point. With Toolset Types, you can create post-relationship that means you can connect posts of post type X with posts of post type Y.

That is why I suggested that you should try to create a test site on our free test platform discover-wp.com and try to play with one of our reference sites to have more control on post-relationship as well as that will help you to learn how post-relationship works with Toolset.

If you have any doubts or you need further assistance, please feel free to contact me 🙂

#1469927

Hi Minesh

Thanks for your time. I will try and play with toolset. It seems that custom post type are the way to create the models of my schema and then lcreate relationships like on my database schema.

Best regards