RoR way to handle 2 situations


#1

I’m new to Ruby on Rails, and was wondering what the preferred method is
of handling the two situations in Ruby on Rails:

  1. You are designing a database table for “Event” that has a
    “recurrence” field. This field should be an integer in the set 0, 1, 2
    meaning “daily”, “weekly”, and “monthly” respectively. Is the preferred
    method to link to a lookup table, or to restrict the possible values
    somehow?

  2. You have designing a database table for “Person” that has an optional
    “birthday” field (you might not know the person’s birthday). How can
    you indicate whether it is valid or not? Is the preferred method to add
    a “isValid” field, or to have another “Birthday” table that may or may
    not be linked in?

Appreciate it!

–RAy


#2
  1. You are designing a database table for “Event” that has a
    “recurrence” field. This field should be an integer in the set 0, 1, 2
    meaning “daily”, “weekly”, and “monthly” respectively. Is the preferred
    method to link to a lookup table, or to restrict the possible values
    somehow?

Another way to do it may be to use integer values for 1, 7, and 30, but
then months aren’t all 30 days apart :(. I think the issue of whether
or
not to use a lookup table is if you might have other apps look at the
database and want to get the value. I suspect I’d go with the lookup
table just to keep it all consistent (in the db).

  1. You have designing a database table for “Person” that has an optional
    “birthday” field (you might not know the person’s birthday). How can
    you indicate whether it is valid or not? Is the preferred method to add
    a “isValid” field, or to have another “Birthday” table that may or may
    not be linked in?

If birthday is NULL then it’s invalid/unknown. Otherwise that is their
birthday. Also, I’d suggest using their birth date so you can
calculate
how old they are as well. Perhaps “born_on”.

-philip