Other tables

In this section, we will discuss the practical usage of the wp_comments, wp_comment_meta, and wp_options tables. The wp_links table is skipped on purpose as we don't generally need it in web application development.

The link manager is hidden by default for new WordPress installations since version 3.5, proving that links are not considered a major aspect in WordPress.

Comments might not indicate a significant value with their default usage. However, we can certainly think of many ways of incorporating comments into web applications. In the previous section, we talked about custom post types. So, what about custom comment types? We can definitely implement custom comment types in web applications. The only difference is that custom post types are defined in the posts table, while custom comment types will have to be handled manually, as they're not currently supported in WordPress.

Let's recall the example in Chapter 1, WordPress as a Web Application Framework, where we created the question and answer interface using posts and comments. Answers were considered as a custom comment type. Similarly, we can match things such as bids in auctions, reviews in books, and ratings for movies as custom comment types to be stored in the wp_comment_meta table. Since the column called comment_type is not available, we have to use a meta key called wpwa_comment_type to filter different comments from each other.

Finally, we will take a look at the wp_options table for system-wide configurations. By default, this table is populated with the settings to run the website. WordPress theme settings will also be stored in this table. In web applications, we will definitely have a considerable number of plugins, so we can use this table to store all the settings of our plugins.

Most of the existing WordPress plugins use a single field to store all the settings as a serialized array. It's considered a good practice that improves performance because of the limited number of table records.

Up until this point, we have explored the role of existing tables and how we can adapt them in real-world web applications. A complex web application will always come up with requirements for pushing the boundaries of these tables. In such cases, we have no option other than going with custom tables, so we will be looking at the importance of custom tables and their usage in the following section.