database design – Key Value Pairs

As we know there is some key value pairs (KVP) using in database design. And it is very common in lots of projects. I forget what the actually purpose is at the moment. But I feel that some KVP design in commercial software product will make the maintenance and development a pain.

The reason is simple, developer needs to convert the key to value in SQL or Java class. Here a sample.

KVP for language

1, “English”
2, “French”
3, “German”
4, “Spanish”
5, “Japanese”
6, “Russian”
7, “Korean”
8, “Mandarin”
9, “Cantonese”
10, “Other”

For the language storage, we save key in module table like language skill, candidate master. When we retrieve the data for candidate or language skill, we need to convert the language key to value so it displays the right text on browser. On the other side, when user searches data with language, like “German”, it needs to convert “German” to “3” so that query can indentify the language key in record.

For this case, I think the KVP is useless. It makes search more complicated.

I remembered that I discussed with some experienced DBA about this long time ago. The one purpose of using KVP in SQL database design is to optimize the storage of data, to save hard drive space. Now a truth is hard drive and memory becomes much powerful and large than before. I think software design is stepping out the time of hardware bound so developer can focus on software creativity than saving hardware resources.

Of course, it doesn’t mean we just throw all KVP in database design. But we had better to keep in mind to change the software design from computer oriented to business oriented.