What is a lookup table?

前端 未结 7 1117
有刺的猬
有刺的猬 2021-01-31 07:59

I just gave a database diagram for a DB I created to our head database person and she put a bunch of notes on it suggesting that I rename certain tables so it is clear they are

相关标签:
7条回答
  • 2021-01-31 08:49

    One use of lookup table is to store otherwise enum values.

    Say, we have a Status enum.

    Instead of saving "Not Started", "In Progress", "Completed", "Sent Back"... in every record in the database, we are saving integer 1, 2, ... only.

    In the programming side, the ORM like Entity Framework can easily convert an underlying integer into an Enum Type.

    In this way, the drawback is the integer value is not readable from the database side. In solving this problem, we add a Lookup Table like

    Id   Status
    1    Not Started
    2    In Progress
    ...
    

    So that our DBA can have a dictionary to "lookup", showing the status text by joining with this lookup table.

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