[wp-hackers] Taxonomy Schema Proposal

Ryan Boren ryan at boren.nu
Sat Apr 21 17:00:55 GMT 2007


On 4/20/07, Mark Jaquith <mark.wordpress at txfx.net> wrote:
> On Apr 20, 2007, at 3:25 PM, Ryan Boren wrote:
>
> > I'm okay with a separate table as long as we're not joining on it
> > everywhere.  The table could hold an auto_increment integer id and a
> > varchar descriptive name.  This could be cached in an array stored in
> > the options table.  Options are autoloaded so we won't be adding extra
> > queries for front page loads.
>
> Why not just have it stored as an option only?  It's not like there
> are going to be a lot of them, and the default ones can be assumed.
> Create an API for it.
>
> function register_taxonomy($name) {
>         if ( !taxonomy_exists($name) )
>                 return (int) create_taxonomy($name); // returns taxonomy id
>         return (int) get_taxonomy_id($name);
> }
>
> And so forth.
>
> Plugin would do:
>
> define('MY_PLUGIN_CUSTOM_TAX_ID', register_taxonomy
> ('my_custom_taxonomy'));
>
> If it needed to do custom queries on that taxonomy id.  Otherwise,
> the built-in functions would do quick queryless taxonomy_name =>
> taxonomy_id conversion out of the in-memory options cache
> ( get_taxonomy_id($name), for instance).

That's fine too.  I think as long as we keep the ID strictly
incrementing and keep track of the current highest ID we are good.

Ryan


More information about the wp-hackers mailing list