Skip Navigation

[Résolu] Use Many-to-Many Post Relationships or Taxonomies?

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:
When and how to use Many to Many relationship

Solution:
Creating many to many relationships is depends on upon the structure of your data. How you setup your post types and taxonomies.

There are 2 ways to establish many to many relationship:
1) Creating Many to Many Relationships Using an Intermediary Object
2) Using WordPress taxonomy

I've described in detail with following reply:
https://toolset.com/forums/topic/use-many-to-many-post-relationships-or-taxonomies/#post-379525

Relevant Documentation:
=> https://toolset.com/faq/how-do-i-associate-one-child-with-several-parents-of-the-same-type/
=> https://toolset.com/documentation/user-guides/many-to-many-post-relationship/

This support ticket is created Il y a 8 années et 1 mois. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

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)

Marqué : 

Ce sujet contient 2 réponses, a 2 voix.

Dernière mise à jour par StefanJ5682 Il y a 8 années.

Assisté par: Minesh.

Auteur
Publications
#379366

We are a media company and will move several sites to WordPress. I am experimenting with Toolset since a couple of months. I have tested with, and created, several post-to-post relationships with many-to-many post relationships, as well as tested with several taxonomies. I have built queries for these, etc. What I need to achieve is primarily to relate "Post Type Companies" and "Post Type Products" to "Posts" (Post here are daily news, articles, interviews, etc.).

My biggest site has about:
- "Posts": 10.000
- Custom Post Type "Companies": 1.000
- Custom Post Type "Events": 1.000

My biggest doubt here is I shall choose to build a relationship between posts and companies/products use a) many-to-many post or b) Taxonomy.

I therefore wonder:
- Which will be fastest in the queries, querying for example for "all posts related to a company".
- Which will generate the smallest database (I guess many to many creates a bigger database as it creates an in-between post for all connections)?
- Which will be easiest to program?
- Which will be easiest to manage in the front end for our journalists?
- Is a Taxonomy list of 1000 companies too long?

I would be grateful for all possible feedback!

/ Stefan

#379525

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

1)
Views is a wrapper (or a GUI) for the native WordPress search, meaning WP_Query instances.

When you start adding filters, it becomes expensive because the database interaction is expensive by itself.
As example, WordPress stores ALL posts in a single Table.

On sites with lots of posts, custom fields and users (and as example wp-types has a high number of these) it means a very expensive database interaction.

Our search does seem simple, but we have to take into account where we search for (titles, content, maybe even fields) and that we need to take out several numbers of content when performing any Search (just remember, ALL posts no matter what type are in one Data Base table…).

Views can handle for sure if your database can handle complex queries for lots of visitors.
Once you get to a point where WordPress WP_Query is not enough, then you need to head to database solutions, which is what we did on wp-types forums as an example.

We do use our own parametric search in https://wpml.org/theme/ and https://wpml.org/plugin/, where we actually list very specific, limited Post Types, filtered by a very limited amount of Meta values.

2)
Regarding your queries:

It looks like indeed you have a large set of data and its and it’s probably faster to query 1000 posts rather than 1000 taxonomies, but being the posts child/ parents , it's again we need to fight with parent/child relationship here.

Even this much amount of data you will use with WP only it will get slow.

“A little”, can become “A lot” when content, meta and users increase, and often Server features dont hold up neither with this.

For example:
300 posts + meta?
1000?
100000?

The number can not be fixed, it depends on your own server performance and load.
Also, on your settings. Just a few examples:
-- Do you have post revisions enabled?
-- Other plugins adding extra tables?
-- How many visitors (that could end up eating the available memory at once) will use this feature on the website?
-- how many plugins you are using?

As you see, we can not tell you “use Views with 100 Users and 10000 Posts”, but “do not use it with the double amount”.

It depends on many factors including also the Server and DDBB.

If you plan to build a website where several users will query the DDBB with Views simultaneously, and you got several Content types and entries, Views might not be the correct Tool, mainly due to the fact, that WordPress itself can not provide the correct DDBB Structure for it, and we do not want to unfollow best practices and begin to add Custom tables to the DDBB.

Answers to your questions:
=============================
- Which will be fastest in the queries, querying for example for "all posts related to a company".
=> As I said due to mass amount of data you are having we can just make it better by establishing post relationship (parent/child) rather than creating taxonomy.

- Which will generate the smallest database (I guess many to many creates a bigger database as it creates an in-between post for all connections)?
=> post relationship will be good idea as taxonomy filters are expensive.

- Which will be easiest to program?
=> Taxonomy is easy but you can choose post relationship for betterment.

- Which will be easiest to manage in the front end for our journalists?
=> depends how you want to manage but in single word post relationship in your case is better.

- Is a Taxonomy list of 1000 companies too long?
=> yes, it is indeed.

I hope this help you to resolve your issue.

#388160

Thanks for detailed and relevant information!

Ce ticket est maintenant fermé. Si vous êtes un client de Toolset et que vous avez besoin d'aide, veuillez ouvrir un nouveau ticket d'assistance