[wp-trac] [WordPress Trac] #14513: Time for a wp_post_relationships table?
WordPress Trac
wp-trac at lists.automattic.com
Sun Aug 8 20:12:48 UTC 2010
#14513: Time for a wp_post_relationships table?
-----------------------------+----------------------------------------------
Reporter: mikeschinkel | Owner:
Type: feature request | Status: closed
Priority: normal | Milestone:
Component: Post Types | Version: 3.0.1
Severity: normal | Resolution: wontfix
Keywords: |
-----------------------------+----------------------------------------------
Comment(by mikeschinkel):
Replying to [comment:39 Denis-de-Bernardy]:
> Replying to [comment:37 westi]:
> > Sometimes you will need more than core to develop a complex site - we
are not trying to solve 100% of use cases only the more significant ~80%.
The other 20% is where plugins sit in the eco-system so that you can make
it your WordPress
>
> Best I'm aware, situations where node2node relationships are desirable
include the vast majority of non-trivial/real-life business applications.
The keyword here is business: people who pay to get a website that is of
any use to them, as opposed to a corporate blog for PR purposes.
Exactly.
I wasn't going to continue, but since Denis did... I'd argue that (what in
WordPress would be) post-to-post relationships are in the 90th percentile
case; certainly not in the 20th percentile. If we accept the custom post
types are WordPress' equivalent of a "relation" (relations are viewed as
"tables"[1]) in the relational model for "large shared data banks" as
written about by E. F. Codd in 1970[2] then this pattern is one of the
most fundamental pattern in relational databases that exist.
The "post-to-post" relationship would be implemented simply with a table
that allows the creation of a many-to-many connection to store as foreign
keys[5] the primary keys[6] of posts, in our case $post->ID. This concept
is fundamental to every relational database system ever built, not some
"''edge''" use case.
Because of it's origins WordPress has nailed the blogging pattern and with
that pattern has implemented many primary key to foreign key
relationships:
* $post->post_parent TO $post->ID
* $term_relationships->object_id TO $post->ID
* $comment->comment_post_ID TO $post->ID
* $postmeta->post_id TO $post->ID
* And several more.
Given WordPress implements the blogging pattern so well maybe it's not
clear that the missing fundamental component required for implementing
generic database-oriented business systems for arbitrary business use-
cases is the post-to-post table aka the many-to-many[7] table.
Alternately we could build out each new use-case pattern for which people
want to use WordPress for much like the blogging use-case pattern was
built out but why go that route (aside from it will never happen) when we
can simply include the low-level many-to-many functionality and let people
build it themselves?
So this is not a stretch nor some obscure need. This is as low a level of
fundamental building block as you can get it WordPress and it's the last
major one that's missing.
* [1]
http://en.wikipedia.org/wiki/Relational_model#Relational_model_topics
* [2] http://www.seas.upenn.edu/~zives/03f/cis550/codd.pdf
* [3] http://en.wikipedia.org/wiki/Relational_model#Examples
* [4] http://en.wikipedia.org/wiki/Many-to-many_(data_model)
* [5] http://en.wikipedia.org/wiki/Foreign_key
* [6] http://en.wikipedia.org/wiki/Primary_key
* [7] http://en.wikipedia.org/wiki/Many-to-many_(data_model)
> One of the more compelling examples Mike gave, IMO, was the one for the
law firm. The little I've worked in that field would have had me laugh at
the idea of using WP. You ''can'' bend reality to make things fit in
taxonomies and meta tables, in order to fit real life situations into an
arbitrary schema. But for such a setup you quickly end up ditching WP
altogether, in favor of Drupal (barely better) or a php framework.
LOL! Denis, PLEASE don't tell my client that! :-) :-) :-) I told them
that WordPress would be better than Drupal or a PHP framework and they are
paying me by the hour to spend hundreds of hours building on that use-
case! (I'm hoping that I'm not proven wrong here.)
FWIW I'm basically building a law firm website plugin that can be used to
launch hundreds if not thousands of law firm websites which is the
business my client is in; managing websites for larger law firms. My code
will be replacing their former custom content management system.
And guess what? I'm developing some potentially really significant
functionality I will be launching as plugins where the functionality is
targeted at developers and themers not at end users. Said another way,
because the company is paying me to build a business system on top of
WordPress (a business system which needs robust post-to-post
relationships, as almost all business systems built on WordPress will
need) I am able to spend lots of time building functionality I can
contribute to the community. (You've probably seen my recent helping of
people on the wp-hackers list; that knowledge came from being commissioned
to delve deep into WordPress and learn it's low-level functionality. Later
contributions will be plugins after I can package and document them.)
But this isn't about me and my development; maybe my stuff is all crap;
who knows? It's about all the other developers who could be commissioned
to build business systems too. And because they would get to focus their
time on developing for interesting business use-cases some of them would
develop generic tool sets and contribute them back to the community thus
growing the use-cases that WordPress can be used for with trivial effort.
But if the only use-case pattern WordPress addresses well is the blogging
pattern then the majority of interesting generic toolsets that will be
contributed back will continue to be by and large for blogging (I'm not
saying WordPress can't currently address those interesting use-cases, it
would just be a lot easier if there were a standard way to relate posts to
posts.)
There are numerous ways to address this need without requiring the
relationships be more complex than a single linking table; I'm just asking
for one of them:
* Add a `wp_post_relationships` table
* Add a "`parent_post`" field to `wp_postmeta`
* Overload `wp_term_relationships` by adding a "`post_id`" field.
* And I am sure there are other ways to tackle this too.
FWIW.
-Mike
--
Ticket URL: <http://core.trac.wordpress.org/ticket/14513#comment:40>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list