[wp-hackers] Time for a wp_post_relationships table?
otto at ottodestruct.com
Tue Aug 3 16:16:34 UTC 2010
On Tue, Aug 3, 2010 at 3:05 AM, Mike Schinkel
<mikeschinkel at newclarity.net> wrote:
> 4.) A movie website could have movies and person-roles where a person-role could be an actor, producer, cinematographer, casting, film editing, costumer, set designer, composer, etc.
I think I'm starting to see what you're talking about here, and why
you need the table the way you want it.
In your design for this one, for example, movies and persons would
both be a custom post type. The person post would then be associated
directly to the movie post and you'd create a "role" taxonomy with
types of relationships to associate the two together in a meaningful
The problem is that I don't think this is the right way to do it. It
seems to me that this is over-generalizing. Instead of "role" being a
taxonomy and having things like "actor" be terms in it, I think using
"actor" as a taxonomy is a better way to go.
Consider your setup. If I wanted to display a list of credits for a
movie, I have to go pull all the related posts for that movie and
possibly parse them to determine names and such. It's a select into
the posts table based on the join, followed by a lot of code to do
But if each role is a taxonomy itself, then the taxonomy name and
terms both have displayable versions that I can use directly. It's no
worse than displaying tags. And if I do want to drill deeper, I can
get related posts by virtue of them sharing terms, and use custom post
types to determine what each type of post is.
I don't think it's necessarily crazy to allow a "thing" to be both a
post type *and* a taxonomy as well. Managing your restrictions on a
per-post basis is simpler than having to select a large number of
posts and then filter through them in different ways for simple tasks.
Keeping the correct terms associated with the correct custom-posts is
not difficult if you abstract out the creation of the posts. For
example, when I make a new actor post, I'd automatically make the
proper term for that actor and auto-tag the post for him accordingly.
The plugin can do this. And then I simply don't give any way to remove
that term from the actor. The taxonomy can be completely managed
behind the scenes, the user doesn't have to manually manage it.
More information about the wp-hackers