We are porting an old application that used a hierarchical database to a relational web app, and are trying to figure out the best way to port configuration switches (Y/N values).
Our old system had 256 distinct switches (per client) that were each stored as a bit in one of 8 32-bit data fields. Each client would typically have ~100 switches set. To read or set a switch, we'd use bitwise arithmetic using a #define value. For example:
if (a_switchbank4 & E_SHOW_SALARY_ON_CHECKS) //If true, print salary on check
We were debating what approach to store switches in our new relational (MS-SQL) database:
- Put each switch in its own field
- Pros: fast and easy read/write/access - 1 row per client
- Cons: seems kludgey, need to change schema every time we add a switch
- Create a row per switch per client
- Pros: unlimited switches, no schema changes necessary w/ new switches
- Cons: slightly more arduous to pull data, lose intellisense w/o extra work
- Maintain bit fields
- Pros: same code can be leveraged, smaller XML data transmissions between machines
- Cons: doesn't make any sense to our developers, hard to debug, too easy to use wrong 'switch bank' field for comparison
I'm leaning towards #1 ... any thoughts?