Table for status

I have a Question which can have many statuses (Open, Closed,
Expired, etc) I have made a Question_Statuses Table to link to my
Question Table. The model by default created by Rails makes the ID
auto increment. I dun want the auto increment so i can change and
delete statuses and have control of them as they link to my questions.

I dunno if there is a better way to do this but i was thinking to have
unique ID’s (no-increment) eg. 1-5 and give them names, and my
questions have a status_id which points to a status.

how would i go about implementing this in rails? and is there a
better way to do it im missing ?

On Nov 17, 2007, at 9:04 PM, Chubbs wrote:

I have a Question which can have many statuses (Open, Closed,
Expired, etc) I have made a Question_Statuses Table to link to my
Question Table. The model by default created by Rails makes the ID
auto increment. I dun want the auto increment so i can change and
delete statuses and have control of them as they link to my questions.

I dunno if there is a better way to do this but i was thinking to have
unique ID’s (no-increment) eg. 1-5 and give them names, and my
questions have a status_id which points to a status.

What is the purpose of having a status table if they are simply
constants?

If you’re depending on the id being a particular value, then why not
just omit the table and assign the status directly to the Question?
On the other hand, if you plan on looking up the description of the
status, then you can’t go around changing them and deleting them
later. If you do, then your Questions will be pointing to either non-
existent or incorrect states.

If your needs are simple, just have a status String in the question
and put the name of the state right in there. As in

question.status = “open”

If you are doing something complex, there’s an acts_as_state_machine
plug-in.

On Nov 17, 2007 9:39 PM, George B. [email protected] wrote:

What is the purpose of having a status table if they are simply
constants?

Normalization. Some DB types feel the DB should hold valid column
values, since it may be accessed in multiple ways.

–Michael

only reason why was having in separate table is so if i wanted to
change the name or add descriptions to the status, or even change the
order etc.

If i was going to store the statuses in the Question table, how would
i define in Rails the global variables for my statuses ?