Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuration storage setup [file vs. database]

Tags:

php

mysql

I see programmers putting a lot of information into databases that could otherwise be put in a file that holds arrays. Instead of arrays, they'll use many tables of SQL which, I believe, is slower.

CitrusDB has a table in the database called "holiday". This table consists of just one date column called "holiday_date" that holds dates that are holidays. The idea is to let the user add holidays to the table. Citrus and the programmers I work with at my workplace will prefer to put all this information in tables because it is "standard".

I don't see why this would be true unless you are allowing the user, through a user interface, to add holidays. I have a feeling there's something I'm missing.

like image 398
Vael Victus Avatar asked Feb 14 '11 21:02

Vael Victus


People also ask

Should I store configuration in database?

It really depends on your application. Storing the settings in the database has several advantages: Security - users can easily alter settings in the file or overwrite the contents. For Distribution - the same settings can be updated and loaded onto any machines on the network.

What is a database configuration file?

What is a Database Configuration File? A database configuration file contains the information needed by WebZ or Database Builder's Record Builder application to interact with a particular database. Each database must have a configuration file. For WebZ, a reference to the file must exist in the databases. ini file.

In which file database configuration is stored?

Correct Option: A. Database table configuration is stored in . hbm file.

What is configuration storage?

Configuration storage refers to stored configuration data in Operations Center as well as data used for version tracking. By default, the data store is an Object ODB that is embedded in Operations Center and installed with Operations Center.


3 Answers

Sometimes you want to design in a bit of flexibility to a product. What if your product is released in a different country with different holidays? Just tweak the table and everything will work fine. If it's hard coded into the application, or worse, hard coded in many different places through the application, you could be in a world of pain trying to get it to work in the new locale.

By using tables, there is also a single way of accessing this information, which probably makes the program more consistent, and easier to maintain.

Sometimes efficiency/speed is not the only motivation for a design. Maintainability, flexibility, etc are very important factors.

like image 68
Jason Williams Avatar answered Oct 08 '22 09:10

Jason Williams


The main advantage I have found of storing 'configuration' in a database, rather than in a property file, or a file full of arrays, is that the database is usually centrally stored, whereas a server may often be split across a farm of several, or even hundreds of servers.

I have implemented, in a corporate environment, such a solution, and the power of being able to change configuration at a single point of access, knowing that it will immediately be propagated to all servers, without the concern of a deployment process is actually very powerful, and one that we have come to rely on quite heavily.

like image 32
Codemwnci Avatar answered Oct 08 '22 11:10

Codemwnci


The actual dates of some holidays change every year. The flexibility to update the holidays with a query or with a script makes putting it in the database the easiest way. One could easily implement a script that updates the holidays each year for their country or region when it is stored in the database.

like image 35
pyasi Avatar answered Oct 08 '22 11:10

pyasi