Strings or Integers for Storing Types in Database
I have a table called
Article with a column called
Status. In the code, the status value is used to indicate whether an article is in draft, pending review, or published state.
I can store those values in the database as integers defined in the code, or use an enum, with
0 for draft,
1 for pending review, and
2 for published. This way is faster to query with, but it is not readable for humans. If a current type needs to be changed or another type needs to be added, then the values would have to be updated accordingly.
On the other hand, I can store those values in the database as strings defined in the code with
Published. This way is readable for humans and slower to query with. If a current type needs to be changed or another type needs to be added, then there probably won't be as much as an issue as with the integer way.
As an alternative, I can use the
CHAR type with
d for draft,
r for pending review, and
p for published, for example.
Which way would you use? Which way seems the cleanest and best able in the long run for scaling web applications?
Add Pages to Vanilla with the Basic Pages app