Results 1 to 5 of 5
Thread: Config Table
Mar 16, 2012, 10:30 #1
- Join Date
- Nov 2004
- 1 Post(s)
- 0 Thread(s)
This is going to sound like a really daft question, I'm sure, but I'm interested in thoughts on how people do this themselves and why they do it in that particular fashion:
Basically, as with most web-apps (though I know not all), we have a config table that holds a load of settings for various uses. When I've done it in the past, the table has been as simple as possible: two columns typically, with a config name, and the value. There may be other columns occasionally, like whether this is mandatory or not, read only (enforced in application), which site it pertains to if the DB supports multiple sites, etc. The value column however has to accept any possible type, so is usually a large varchar(). Types are all enforced in the application.
In this method, I would "SELECT conf_val FROM conf_table WHERE conf_key = 'siteadmin';" for example
However, at the company I work for now, they rotate everything around 90° and they have one single row of data, and each config key is a column name. This gives them the added advantage that the types are correctly maintained (the tax value in eCommerce for example cannot be text, as the column type is decimal). The problem I have though is that it's a pain to find the data, and if I want to add an extra value for any reason then I need to alter the table before I can add it, instead of just being able to add another row. There's also no indexing and worst of all, no PK, so it's possible to have multiple rows with conflicting values.
In this method, I would "SELECT siteadmin FROM conf_table;" for example, assuming that an extra row has never crept in anywhere and any how. Then again, updates are usually to set a column value without any conditions, so all rows take the same value.
So, I'm curious about how people do it themselves, why, and what pros and cons you see to both. I'm wondering about whether it's worth updating ours to my preferred method, or whether I'm better to just put up with it how it is