How important are lookup tables?

后端 未结 7 2002
你的背包
你的背包 2020-12-08 02:51

A lot of the applications I write make use of lookup tables, since that was just the way I was taught (normalization and such). The problem is that the queries I make are of

相关标签:
7条回答
  • 2020-12-08 03:35

    The commenters have convinced me of the error of my ways. This answer and the discussion that went along with it, however, remain here for reference.

    I think a constant is appropriate here, and a database table is not. As you design your application, you expect that table of statuses to never, ever change, since your application has hard-coded into it what those statuses mean, anyway. The point of a database is that the data within it will change. There are cases where the lines are fuzzy (e.g. "this data might change every few months or so…"), but this is not one of the fuzzy cases.

    Statuses are a part of your application's logic; use constants to define them within the application. It's not only more strictly organized that way, but it will also allow your database interactions to be significantly speedier.

    0 讨论(0)
提交回复
热议问题