Suppose there is a User , which has 2-3 status "pending" , "active" , "blocked" .
To preserve integrity, there is a table statuses :id, :name
Well, 2 options to set this status.
1) It seems to me that it is better to make the primary key name , refusing from id hang a foreign key on this field.
Then you can do User.set_status("active")
2) Colleagues say that this is the wrong approach. It is necessary that the id was required. This will allow faster search, about some tree indexes say.
However, during the development process, the status setting is complicated.
status_id = find_status_by_name("active") User.set_status(status_id) Tell me pliz than the 1st option, so much worse than the second?
With my Noob look, I see only the minuses of the second variant and the advantages of the first one.
CREATE TYPE user_status AS ENUM ('pending', 'active', 'blocked');- Fat-Zer