WordPress.org

Ready to get started?Download WordPress

Forums

Coding Issue - Relational Databases (6 posts)

  1. SergeBenard
    Member
    Posted 1 year ago #

    Hello.

    My questions are:

    • 1) How do I approach creating relational database tables and maintain their relationships throughout the web app?
    • 2) Where in the documentation should I look for more information?

    The simplified database schema.

    I want to be able to manage the Image Categories, Images, Image Comments and the Canned Comments in the backend.

    Again, the questions I have are:

    • 1) How do I approach creating relational database tables and maintain their relationships?
    • 2) Where in the documentation should I look for more information?

    I am more than happy to clarify the question if there is any need to.

    Thanks a lot gang.

  2. bcworkz
    Member
    Posted 1 year ago #

    You will develop a plugin to interface with WP. You will access the database using $wpdb methods. You could either create the tables manually with myPhpAdmin if this is a one off app, or via the plugin activation hook.

    The relationships are defined by how you construct the SQL queries. You will want to develop a series of functions that add an abstraction layer between procedural code and the database. Functions like list_image_comments() and such to establish relationships and to avoid writing mySQL queries every time you want something out of the database, just as WP does with it's data. This is best done by defining class properties and methods, but not a requirement.

    If you are looking for examples, you don't need to look much farther than the WP source code itself.

  3. SergeBenard
    Member
    Posted 1 year ago #

    This sounds exactly like what I needed to hear. I was having a difficult time wrapping my head around this issue.

    To confirm that I have it understood, can you answer this for me please:

    To make my app work, I'd be building the app as if it were stand-alone, but using the WordPress API and WP's coding best practices?

    For example:

    // Store table name in variable before creating it
    $table_name = $wpdb->prefix . "cannedcomments";
  4. bcworkz
    Member
    Posted 1 year ago #

    Generally, yes that is what I'm thinking. Of course, there will be departures. How they are handled is a judgment call, do your best. For example, in your example code snippet, you might choose to not use table prefixes for some reason. If you have a valid reason, no problem. Without a logical reason, then yes, following WP best practice is a good idea.

  5. SergeBenard
    Member
    Posted 1 year ago #

    Thank you very much, this is great. Thanks for your time!!

  6. davekorpi
    Member
    Posted 1 year ago #

    I sooooo need help and happy to pay. I need a relational database that has a "key" of "customer number" that relates the database of information similar to that Serge described... Anyone interested in doing consulting? Is that allowed to ask on this forum? You can find me everywhere on the web if you search provisional patent video course

    Thanks a million!

    THEN.. what I want to do is to be able to POPULATE this database with an embedded system that can only use HTML using a TCPIP stack using a wireless modem... Crazy right!!??

Topic Closed

This topic has been closed to new replies.

About this Topic