In developing a shopping cart application I've found that I needed to save settings and configurations based on the administrator's preferences and requirements. This information can be anything from company information, Shipping account IDs, PayPal API keys, notification preferences, etc.
It seems highly inappropriate to create a table to store a single row in a relational database system.
What is the appropriate way to store this information?
Note: my DBMS is SQL Server 2008 and programming layer is implemented with ASP.NET (in C#).
I have done this two ways in the past - a single row table and a key/value pair table - and there are positives and negatives to each approach.
The single row option is by far the easiest one to work with. This is because you can store each setting in its correct type in the database and not have to store the types of the settings as well as their lookup keys in code.
One thing I was concerned with using this approach was having multiple rows in the "special" single row settings table. I overcame this by (in SQL Server):
This means that only one row can exist in the table because the bit column has to have a value of 0, but there can only be one row with that value because of the unique constraint.