Using a Single Row configuration table in SQL Server database. Bad idea?

后端 未结 12 1951
终归单人心
终归单人心 2020-12-12 09:19

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 info

12条回答
  •  粉色の甜心
    2020-12-12 09:45

    I'm not sure a single row is the best implementation for configuration. You might be better off having a row per configuration item with two columns (configName, configValue), although this will require casting all of your values to strings and back.

    Regardless, there's no harm in using a single row for global config. The other options for storing it in the DB (global variables) are worse. You could control it by inserting your first configuration row, then disabling inserts on the table to prevent multiple rows.

提交回复
热议问题