Best Way To Store Multiple Flags In Database

前端 未结 5 775
天涯浪人
天涯浪人 2020-12-16 14:51

I have a web-based application that notifies users of activity on the site via email. Users can choose which kinds of notifcations they want to receive. So far there are abo

5条回答
  •  再見小時候
    2020-12-16 15:53

    If you do decided to use a bit field like @stephenbayer mentioned you can always use a view on the table to make it easier for developers to use. This then means that you still have the space savings of the bit field and the ease of use of separate columns per field and while avoiding having to parse the column.

    As mentioned the separate table is an excellent option if you want your solution to be more extensible. The only downside is slightly increased complexity.

    This is the trade off. If you want something that is really easy to implement and is fast consider the bit field. If you want something that is easier to extend and maintain at the cost of slightly more complexity then by all means go for the separate table. If the votes tell you anything you probably want to follow the separate table implementation.

提交回复
热议问题