Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuration in a File or a Database?

Tags:

I'm not really asking whether I should use either a RDBMS or config files for 100% of my application configuration, but rather what kind of configuration is best addressed by each method.

For example, I've heard that "any kind of configuration that is not changeable by the end-user" should be in config files rather than the database. Is this accurate? How do you address configuration?

(I'm primarily concerned with many-user web applications here, but no particular platform.)

like image 222
Brian Sullivan Avatar asked Jan 28 '09 14:01

Brian Sullivan


People also ask

What is configuration file in database?

The database configuration file (by default, named MFDBFH. cfg) is used by the native database file handler (MFDBFH), and for enterprise server region management. It contains a list of database server instances, the databases available within them, and connection details.

Is it better to keep configurations in config file or database?

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

Which file contains the 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.

Where is the configuration file?

Configuration files are normally saved in the Settings folder inside the My Documents\Source Insight folder.


2 Answers

I find that during development it is of great benefit to have configuration stored in a file.

It is far easier to check out a file (web.config, app.config, or some custom file) and make changes that are instantly picked up when the code is run. There is a little more friction involved in working with configuration stored in a database. If your team uses a single development database you could easily impact other team members with your change, and if you have individual databases it takes more than a "get latest" to be up and running with the latest configuration. Also, the flexibility of XML makes it more natural to store configuration that is more than just "name-value" pairs in a file than in a relational DB.

The drawback is where you want to reuse the configuration across multiple apps or web site instances. In my own case, we have a single config file in a well-known location that can be referenced by any application.

At least, this is how we store "static" configuration that does not have to be updated by the system at runtime. User settings are probably more suited to storage in the DB.

like image 186
freshr Avatar answered Oct 13 '22 22:10

freshr


The oneliner: As a general principle - the more likely the config data should change the better to put it into db.

The legal disclaimer: You would need to have almost always a kind of "bootstrapping" configuration, which must be saved into a file, thus if you are using a db to store your configuration the size of the "bootrapping" conf would depend on the other great principle: "Work smarter not harder !!!"

like image 22
Yordan Georgiev Avatar answered Oct 13 '22 21:10

Yordan Georgiev