Using posts and postmeta table to store custom Address Book Plugin data

On close inspection of WP, I realize that almost all the information is in the table posts and postmeta.

Do you think we should follow this example and put all our information in these table posts & postmeta?

I am creating a plugin “Address Book”, do I need to create a new table wp_addressbook or do I insert my address book in the table posts (will I have to choose the fields)?

What are the advantages and disadvantages of “putting everything” in the posts table?

Solutions Collecting From Web of "Using posts and postmeta table to store custom Address Book Plugin data"

Using posts & postmeta:

There is nothing wrong in using posts and postmeta table for custom database requirements.

In WordPress, although posts & postmeta table was originally there to create blog posts, later it evolved to cover many different sorts of database requirements. Using Custom Post Types, Post Meta & Custom Taxonomies, you can satisfy most database requirements generally used in web development.

In your case, you may use Custom Post Types (for address book), Post Meta (for custom address book fields) & Custom Taxonomies (for custom categorization or grouping of address book entries).

Advantage:

  • You’ll be able to use tried and tested WordPress core functions to manage the data.

  • Tons of Plugins & Themes will support this, so you’ll be able to use them to enhance your development further.

Disadvantage:

  • The database will not be 100% tidy, i.e. there will be redundant columns.

  • DB query may not be 100% optimized (may be 99%) compared to a custom DB structure.

Check WordPress Database structure to make a more informed decision.

Creating custom DB structure:

You really don’t need to create custom DB tables for this. However, if you feel necessary, you may follow this doc.

Advantage:

  • You may design a 100% tidy relational DB structure, i.e. no redundancy.

  • You may optimize 100% to your heart’s content.

Disadvantage:

  • You’ll have to spend a ton of time to apply all the security, efficiency & usability measures already taken care of in WordPress core and many useful optimization related plugins.

  • Available plugin & theme compatibility will be difficult to maintain.

  • All the time spent may not worth the little benefit you may or may not gain.