In the "lookup table" or not?

I am currently developing a database for the project. Now I’m discussing myself whether I need to create a look-up table, for example, “civil status” data, which can contain only fixed values, such as Single, Married, Separated, Widow / Widower. I am sure that no other values ​​will be added in the future. Should I put them in a separate table or just hardcode the values ​​of the program code?

+3
source share
6 answers

What is the advantage of hard coding? Given the modern ORM system, is it not easy to read these values ​​from the database and use them? If so, then I do not see the benefits of hard coding when the cons:

  • You will need to redeploy if you want to add it to the list.
  • You will need to reinstall if you want to change the spelling
  • You probably want to have more than just a string (maybe a ref-id or tooltip text, etc.).
  • You will need to change 1000 entries to change the saved text if you do not store the ref-id.

“I can’t think that they will change” almost never coincides with “They cannot change.” If they cannot change, as in True / False, then in order. If you do not think that they will change, not so much.

+7

:

:

" " , - .

-, , Andrew Kennan .

+3

. , , , , , .

, ? ? True/False?:)

Java , . MySQL, . .

+1

CivilStatus (int), CivilStatuses, .

, , . , , /.

, , . , , , .

+1

- , .

, - , .

0

. ?

1) . , .

2)

3) . .

Select * from People where MarriageStatus = "single" or is it "Single", or is it "SINGLE"

, , ToLower (MarriageStatus) = "single". , , :)

, .

0

All Articles