Flags in a database rows, best practices

前端 未结 8 1574
南旧
南旧 2020-12-16 09:34

I am asking this out of a curiosity. Basically my question is when you have a database which needs a row entry to have things which act like flags, what is the best practice

8条回答
  •  星月不相逢
    2020-12-16 10:14

    If you really need an unbounded selection from a closed set of flags (e.g. stackoverflow badges), then the "relational way" would be to create a table of flags and a separate table which relates those flags to your target entities. Thus, users, flags and usersToFlags.

    However, if space efficiency is a serious concern and query-ability is not, an unsigned mask would work almost as well.

提交回复
热议问题