Custom relational database in a WordPress installation
-
Hello all
This isn’t so much a ‘how to’, as a request to be pointed to roads to go down to get to my destination. In brief, my query is: how can I create a relational database in the WP database, and use forms to populate and query it?
In more detail:
I’m after creating a links ‘repository’ for subjects (eg healthcare, languages), which would be a multi-table relational database. For instance, I developed the Global Health repository as a custom web app, using PHP, MySQL and Codeigniter at the back end. Contributors add a web resource by URL, name, keywords, topic and a few other criteria, and this data goes into a MySQL database with around ten tables, linked by foreign keys or junction tables.
What I’d like to do is write a plugin to enable such a repository in WordPress. An example of a repo I’d like to transfer into WP is a healthcare resources database. I’d like to do this for the plugin writing exercise, to contribute a little back to the community, and to provide a simple tool for the user to create their own link repo in whatever subject they want. The end user should be able to search/browse for resources in that subject via a simple form.
So I may want to add custom tables to the WP database and relate them as I want. I’m not sure, though, about the best way of approaching this. I’m thinking that I could maybe use the excellent Advanced Custom Fields plugin with some Custom Post Types, and use the dbDelta() function to create tables on plugin activation as advised in this article.
Alternatively, perhaps I shouldn’t mess about with the WP database, but rather create a separate DB and run queries on that from within WP.
There could be a number of roads to go down, but I’d prefer to avoid those that may lead to dead ends, hence this rather fluffy query to the WP community. How would youse go about doing this sort of thing? Am I duplicating the work of an existing plugin? (I did search the plugin repo under various keywords but got 00s of hits.) Am I barking up the wrong tree completely?
If this post should go into the Plugins forum, let me know and I’ll repost it there.
- The topic ‘Custom relational database in a WordPress installation’ is closed to new replies.