# RoR way to handle 2 situations

**URL:** <https://www.ruby-forum.com/t/ror-way-to-handle-2-situations/107843>\
**Category:** Rails\
**Created:** [June 26, 2007, 7:54pm UTC](https://www.ruby-forum.com/t/ror-way-to-handle-2-situations/107843 "2007-06-26T19:54:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ray\_Wenderlich](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f17d59/32.png) [@Ray\_Wenderlich](https://www.ruby-forum.com/u/Ray_Wenderlich)\
**Post date:** [June 26, 2007, 7:54pm UTC](https://www.ruby-forum.com/t/ror-way-to-handle-2-situations/107843/1 "2007-06-26T19:54:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ray\_Wenderlich](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f17d59/32.png) [@Ray\_Wenderlich](https://www.ruby-forum.com/u/Ray_Wenderlich)\
**Post date:** [June 26, 2007, 8:29pm UTC](https://www.ruby-forum.com/t/ror-way-to-handle-2-situations/107843/2 "2007-06-26T20:29:13Z")

</div>

> 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
