Flags in a database rows, best practices

前端 未结 8 1561
南旧
南旧 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:07

    A Very Relational Approach

    For databases without the set type, you could open a new table to represent the set of entities for which each flag is set.

    E.g. for a Table "Students" you could have tables "RegisteredStudents", "SickStudents", TroublesomeStudents etc. Each table will have only one column: the student_id. This would actually be very fast if all you want to know is which students are "Registered" or "Sick", and would work the same way in every DBMS.

提交回复
热议问题