This is more of a design issue I’m wrestling with, and was wondering
what other people are doing.
I have a products table with status values of In Stock, Out of Stork or
Discontinued. This is unlikely to change any time soon.
Approach A, is to have thses actual values in the status column, at
least the meaning is very apparent, yet querying for products with a
specific status could be problematic if due to a business decision the
description had to be changed, e.g. Out of Stock became Not in Stock.
Approach B, is to have a code that represents the status, such as I, O,
D, querying would work, and their descriptions could change. But when
the data was displayed the code would have to be translated to a
description every time.
Approach C, have a new status look up table, which would have an id
column and a description, and the products table would then have a
status id, which if the description was required would include the
status table in the find. This seems a bit over the top but maybe is the
cleanest way and status can be added and descriptions changed without
any changes to application code.
Approach D, have a new table with status codes I, O, D but that would
mean hard coding a lot of the queries as find_by_sql, to have the table
join, as there is no id column on the status table.