Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it a bad idea to have a property table in a database?

Often, when I need to store system properties like admin info, versions, and so on, I use a flat file (database.properties, init.properties, etc). This seems common in other programs that I see and use on a daily basis.

Sometimes a flat file isn't ideal for a number of reasons. Deploying a web app to numerous clients often comes with limitations. In these cases, I use a database table to hold the information. For example, let's say I have some admin data that I wish to save, and perhaps some specifics about my environment. I might do something like this:

property_entry_table

[id, scope, refId, propertyName, propertyValue, propertyType] 
1, 0, 1, "DB_VER", "2.3.0", "FLOAT"  
2, 0, 1, "LICENCE", "88475", "INT"  
3, 0, 1, "TOP_PROJECT", "1", "INT"   
4, 0, 1, "SHOW_WELCOME", "F", "BOOL"  
5, 0, 1, "SMTP_AUTH", "SSH", "STRING"  
6, 1, 1, "ADMIN_ALERTS", "T", "BOOL"

I realize this breaks SQL's typing and allows me to store all sorts of types as strings. Is this good practice or have I been going about this the wrong way?

If not, in what way should I be storing this type of info?

like image 440
Stephano Avatar asked Feb 23 '10 19:02

Stephano


People also ask

What type of data you should not store in a database?

Finally, you shouldn't store credit card information in your database unless you absolutely need to. This includes credit card owner names, numbers, CVV numbers, and expiration dates.

What constitutes a bad database design?

A badly designed database has the following problems: Related data is scattered over various tables. A change must be updated at many places. It's possible that the information is only half present, it's there in one table, but missing in another one.

What are the undesirable properties of bad database design?

A bad design may have several properties, including: Repetition of information. Inability to represent certain information. Loss of information. and suppose an instance of the relation is Figure 7.1.


1 Answers

I think this is fine but you might want to consider caching your data in memory when you read it so that you don't have to keep going back to the DB. If you cache your data then store it wherever will make your updates the easiest. The advantage of housing the data in your DB is that it might be easier to maintain or create interfaces to manage those properties especially once you start to use a distributed environment for you application.

like image 90
Middletone Avatar answered Nov 15 '22 07:11

Middletone