For example, there is a table "products". For products, you need to add a "status" field with their status (moderated | active | blocked). How is this field better organized?

  1. You can leave it just plain text, but then redundant data will be stored. Plus, if you want to rename the status from one to another, you will have to rename all previously added products with this status.

  2. You can select a separate table "products_status", and bind it by the ratio 1k1. But here, too, get their cons:

First of all, when adding, I don’t know what id to substitute into the status, and I’ll have to get the status of interest first, and then substitute its id into the "products" table.

Secondly, it seems a bit redundant for each column with multiple fill options to create a new table. From this number of tables in the database will double, if not more.

Tell me how to be better, or maybe I'm in something wrong.

  • one
    Here the type enum mysql.ru/docs/man/ENUM.html will do - Nikita Umnov
  • It will relieve redundancy, but if you need to rename one of the values, you will need a small tambourine) - Nikita Umnov
  • Thank. That is quite enough) - Bonfire

0