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).