in reply to mapping complex structures to mysql tables

I use a simple key/value configuration table for site wide things such as webmaster email addresses. I find it hard to imagine site wide configuration data with a more complicated structure than key/value pairs that shouldn't be in a specific table of its own. Can you give examples of the sort of site wide configuration data that is problematic?

If the configuration data only applies to part of the site it should be handled by the code that manages that part of the site and should either store the configuration in existing relevant tables, or should add configuration tables specific to the site area as required. It may be useful to write a base class that does most of the common heavy lifting for managing configuration data then provide site area specific derived classes as required.

True laziness is hard work
  • Comment on Re: mapping complex structures to mysql tables

Replies are listed 'Best First'.
Re^2: mapping complex structures to mysql tables
by salva (Canon) on May 09, 2013 at 10:15 UTC
    That's also what I do!
Re^2: mapping complex structures to mysql tables
by niubi (Initiate) on May 09, 2013 at 11:35 UTC
    Sorry, I can't provide any real life details about the data (I have signed a very tight NDA and the company I work for is very picky about that), but I can assure you that this configuration variables are needed and can't be simplified. Also, this settings define how a specific part of the website works and the number and types of settings vary dynamically, and each section could have different settings, that's why hardcoding is out of the question

    Currently, the site currently works as yout suggested solution (I have defined a class that sets all this configuration variables) but my boss wants the possibility that anyone can access and edit the settings without the need to know and/or modify any piece of perl code and he wants that information to be in MySQL.

      The significant part of my "solution" was:

      store the configuration in existing relevant tables, or should add configuration tables specific to the site area as required

      so if "the site currently works as yout suggested solution" then you have no problem.

      If "boss wants the possibility that anyone can access and edit the settings" that implies to me that you need to add some sort of administrative access configuration panel to your site. Allowing configuration by direct access to raw configuration data is a recipe for major disaster!

      True laziness is hard work
        I certainly know the implications of allowing people access to editing settings (like the one you mention), but that is irrelevant to the problem I want to solve (that is, store complex data structures in MySQL in a way that is easy to edit the settings stored), that's why I haven't mentioned those issues.

        I also know that this solution is not optimal (I already discussed this several times with my boss), but it is THE solution my boss wants and he is the one that pays me, so I do what he says :)