Storing multiple choice values in database

前端 未结 9 2133
猫巷女王i
猫巷女王i 2020-12-10 21:24

Say I offer user to check off languages she speaks and store it in a db. Important side note, I will not search db for any of those values, as I will have some separate sear

9条回答
  •  生来不讨喜
    2020-12-10 21:49

    Premature optimization is the root of all evil.

    EDIT: Apparently the context of my observation has been misconstrued by some - and hence the downvotes. So I will clarify.

    Denormalizing your model to make things easier and/or 'more performant' - such as creating concatenated columns to represent business information (as in the OP case) - is what I refer to as a "premature optimization".

    While there may be some extreme edge cases where there is no other way to get the necessary performance necessary for a particular problem domain - one should rarely assume this is the case. In general, such premature optimizations cause long-term grief because they are hard to undo - changing your data model once it is in production takes a lot more effort than when it initially deployed.

    When designing a database, developers (and DBAs) should apply standard practices like normalization to ensure that their data model expresses the business information being collected and managed. I don't believe that proper use of data normalization is an "optimization" - it is a necessary practice. In my opinion, data modelers should always be on the lookout for models that could be restructured to (at least) third normal form (3NF).

提交回复
热议问题