For some time, there has been a debate among WordPress developers about adding additional meta tables, like wp_postmeta and wp_usermeta.
The only thing that everyone seems to agree on is that a unified API for accesing metadata is necessary.
I propose we add meta tables on demand: Have a function that adds meta tables only when required by a plugin.
For example, if a plugin needs wp_commentmeta, it could do something like this:
register_activation_hook(__FILE__, 'need_commentmeta');
function need_commentmeta() {
enable_meta_table('comment');
}
The enable_meta_table() function would check if wp_commentmeta exists and create it if it doesn’t. After that, the plugin can use the table without worries.
Advantages of this approach:
- no database bloat: there won’t be any meta tables that aren’t required
- separate tables: it was noted that having a single meta table would affect performance
- extensible: the enable_meta_table() could be made to accept new meta types
I think this approach would allow both consistency and flexibility.