Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is it better to store platform configuration in database or a file?

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

like image 510
Pavel K. Avatar asked Dec 03 '09 17:12

Pavel K.


People also ask

What is the correct directory which store configuration files and software packages?

All configuration files are in /etc , all binary files are in /bin or /usr/bin or /usr/local/bin .

In which file do we need to do database configuration?

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.

Which directory is used to store configuration files?

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.


2 Answers

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

like image 160
Greg Beech Avatar answered Oct 01 '22 03:10

Greg Beech


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.

like image 32
Jé Queue Avatar answered Oct 01 '22 05:10

Jé Queue