Answer the question
In order to leave comments, you need to log in
How to properly store the status of a post/announcement/other?
Records should be stored in the database on the site, each has a status: published/rejected/under moderation.
How to store this status?
The solution "on the forehead" is to make the "status" field of the tinyint type and where 1 - it is published, 0 - rejected, 2 - on moderation. But how right is this?
Or make a separate "status" table, where all statuses will be stored, and in the table with records, make the "status_id" field, which will refer to the table with statuses? Or in some other way?
Answer the question
In order to leave comments, you need to log in
Where to store?
1. If you need to change the name of the statuses through the user interface and constantly add / delete / edit, then the statuses should be stored in the database in a separate table with customized keys.
2. If the statuses rarely change, then you have the right to implement them at the code level (in the class with constants or in another way).
1. If you are chasing every millisecond in queries, then use a number.
2. If you want to work with the database in a more human-readable language, then use the string state of the statuses (new, reject, closed, cancel, active...). Working with such data is much easier than remembering what 1 means, what 2 means, and so on.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question