[wp-hackers] Database structure Wordpress

Mike Schinkel mikeschinkel at newclarity.net
Fri Dec 4 13:05:03 UTC 2009


On Dec 4, 2009, at 6:20 AM, scribu wrote:
> On Thu, Dec 3, 2009 at 9:53 PM, Mike Schinkel
> <mikeschinkel at newclarity.net>wrote:
> 
>> To use an example more concrete for WordPress, let's say you have two
>> custom post types, "Products" and "Companies."  You could end up with three
>> tables to manage this with one-to-one relationships between posts and
>> products and between posts and companies:
>> 
>> wp_posts
>> wp_custom_products
>> wp_custom_companies
>> 
>> To see this structure in action look at Drupal's CCK module or the PODs
>> plugin for WordPress.  And it is relationally correct.
>> 
>> But again, this should probably be an option to the current metadata table
>> approach for only if and when it is needed.
>> 
> 
> Given the principle that WP schema only contains tables that are actually
> used by Core, it's pretty clear that this is plugin territory.
> 
> There aren't enough different columns between post, page & attachment to
> warrant this approach.
> 
> Plus, the meta tables offer a lot more flexibility.
> 
> Also, there's nothing preventing you from building a custom table with
> certain columns that you need to do complex queries with.

FWIW I made some comments on the database thread yesterday that explained pros and cons of the above approach vs. the metadata approach. For complex relationships the above beats out metadata structures hands down but I lamented that we'd probably never see it in WordPress core because of the WordPress team's bias.  I wrote the above as if a continuation of that prior thread.

-Mike


More information about the wp-hackers mailing list