Many to many to many custom post relationships

I’m building something similar… I’ll explain my logic but keep in mind that this Question and my subsequent Answer may get downvoted because it’s all vague and theoretical and technically there’s probably more than one way to do it, so accepting the correct answer will be difficult. Anyway…

I’m building a soccer league management tool and the many-to-many relationship works along the same lines.

So what I did was try to flesh out the different relationships on paper and then determine which of them are custom taxonomies and which of them are custom post-types.

Off the top I would think that your classes (dressage, cross-country, etc.) would be taxonomies

The riders and horse can share the taxonomy, and could be custom post-types.

Not sure how much data you’re placing into the “Competitions” but that could be a taxonomy as well, unless you have to do a lot of work with them, then they’d need to be a CPT.

So, on a simple stream… I’d say you could set Rider A and Horse 12. Then assign them a their Class taxonomies. So both Rider A and Horse 12 are participating in Dressage.

Now, if the Competition is a taxonomy as well, let’s say the “Summer Sunrise Competition”, you can then assign that to both Rider and Horse.

Once you save the post, you could then generate a custom meta on either Rider or Horse (your choice depending on operational logic and internal processing)… that custom meta would take every combination of taxonomies and ask you to associate an entry from the other CPT.

So, let’s say you assign horses to riders most commonly…

You’d have the Rider A CPT.

Dressage Class
Cross Country Class

Summer Sunrise Comp.

That would generate, after saving, 2 custom fields, where you would then assign a horse.

Rider A -> Dressage ->
Summer Sunrise Comp. -> Riding Horse 12

Rider A -> Cross Country -> Summer Sunrise Comp. -> Riding Horse 8

Then on the CPT Post for Horse 12 & Horse 8, you’d provide a similar logic, except instead of letting the user input the Rider, you’d query the Riders based on matching taxonomies, and see who has Horse 12 assigned and then put a link to their CPT Rider Post.

(The above is all admin stuff.)

Anyway, without knowing all about the sport, that’s a basic outline of how I’d approach it.)