currently we are developing an app in which we use database table to store platform settings, like maximum file size, maximum users number, support email, etc.
it means that each time we add a platform setting we have to add a column to this table.
in my previous projects i am used to store such information in file.
what is better/faster approach?
ps, i am almost sure someone already had such question, but i can't seem to find it
All configuration files are in /etc , all binary files are in /bin or /usr/bin or /usr/local/bin .
A database configuration file is created for each database. This file is called SQLDBCON prior to Version 8.2, and SQLDBCONF in Version 8.2 and later. The creation of this file is done for you.
Most global config files are located in the /etc directory. The /etc/ directory feels more like a filesystem and has many sub-directories, each having related config files.
We store config settings in a key/value type table, something like:
CREATE TABLE Configuration.GlobalSettings ( SectionName VARCHAR(50), SettingName VARCHAR(50), SettingValue VARCHAR(1000), SettingType TINYINT );
The SectionName
& SettingName
are the primary key, we just split them up to make it easier to query what is in a section, and to allow the loading of individual sections into handlers rather than loading the whole lot at once. The SettingValue
is a string, and then the SettingType
is a discriminator that tells us how the setting value should be interpreted (e.g. 1 = string, 2 = bool, 3 = decimal, etc.).
This means you don't have to change the table structure for new settings, just add a new one in the deployment script or wherever it is you set these things up.
We find it a better way do do config than a file because it means you can easily programmatically change config values through an admin interface when needed, which can enforce logic around what can go into each setting. You can't do that so easily with a file (though, of course, it is possible).
I can tell you as I manage a particularly large application at numerous sites that keeping configs in local files is a complete pain. Often times the configs are read and cached and not able to be changed during run time others have scale-out systems where configs need to be repeatedly changed and bounced.
My life would be 10% easier during system landscape implementation if the designers would just keep system properties at the DB.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With