Answer the question
In order to leave comments, you need to log in
SQL DB - are magic numbers normal in DBs that have constants in the back end code? Or is it better to make a table and a relation?
Hello. I am writing an online store. And now the product has statuses - hidden, shown. Or a tag - hidden, shown, forbidden to be created (some swear word, for example).
In the database, this field is 0 - hidden, 1 - shown, 2 - disabled.
I have a Status class in php and it has constants that expose these values:
const STATUS_HIDDEN = 0;
const STATUS_VISIBLE = 1;
const STATUS_BANNED = 2;
Answer the question
In order to leave comments, you need to log in
As practice in living projects has shown, "1,2,3 and will never expand" - it expands quite quickly)
As examples: until recently the gender was M or F and it was possible to hardcore ... already there is no such thing ...
Well, the reference table is good a place to store description variations ("prohibited", "prohibited for sale") for different display cases.
ps By the way, why not be a product shown only to certain groups? (here is the 4th option for what cannot be changed)
I think it's normal to have such things entirely in php, and keep just a tinyint in the database
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question