# Setting up proper relationships

**URL:** <https://www.ruby-forum.com/t/setting-up-proper-relationships/109537>\
**Category:** Rails\
**Created:** [July 16, 2007, 3:38pm UTC](https://www.ruby-forum.com/t/setting-up-proper-relationships/109537 "2007-07-16T15:38:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pabloz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c37758/32.png) [@pabloz](https://www.ruby-forum.com/u/pabloz)\
**Post date:** [July 16, 2007, 3:38pm UTC](https://www.ruby-forum.com/t/setting-up-proper-relationships/109537/1 "2007-07-16T15:38:20Z")

</div>

Hi

I am trying to make a small survey app and started to get a little  
confused. So far i have

survey.rb  
has\_many :answers

answer.rb  
belongs\_to :survey

So Survey will have many answers, and answer will belong to only one  
survey. This part works fine. Now i want to record survey results (you  
can only pick ONE answer, it will NOT be a multiple answer survey).

To do this, as far as i know i should create anwsers\_surveys table and  
setup proper habtm relations or create a new model and go with :through.

Is this the way to go?, since i am not really trying to make a real  
habtm between surveys and answers but need to record the results.

---

<div class="post-metadata">

**Author:** ![pabloz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c37758/32.png) [@pabloz](https://www.ruby-forum.com/u/pabloz)\
**Post date:** [July 16, 2007, 3:48pm UTC](https://www.ruby-forum.com/t/setting-up-proper-relationships/109537/2 "2007-07-16T15:48:23Z")

</div>

why not just have a score column in the answers table?

---

<div class="post-metadata">

**Author:** ![pabloz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c37758/32.png) [@pabloz](https://www.ruby-forum.com/u/pabloz)\
**Post date:** [July 16, 2007, 4:23pm UTC](https://www.ruby-forum.com/t/setting-up-proper-relationships/109537/3 "2007-07-16T16:23:00Z")

</div>

Pawel Jur wrote:

> Is this the way to go?, since i am not really trying to make a real  
> habtm between surveys and answers but need to record the results.

Pawel,

Step back from ActiveRecord for a bit and examine your problem domain.  
If a survey can have multiple answers and and answer can have multiple  
surveys then you have already answered your own question! i.e. you  
will need a link table either with the habtm (deprecated) or the first  
class model approach (:through)

I write this response with the assumption that “answer” is equivalent to  
“result”. If I am mistaken then please forgive the confusion.

HTH ilan

---

<div class="post-metadata">

**Author:** ![pabloz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c37758/32.png) [@pabloz](https://www.ruby-forum.com/u/pabloz)\
**Post date:** [July 16, 2007, 6:38pm UTC](https://www.ruby-forum.com/t/setting-up-proper-relationships/109537/4 "2007-07-16T18:38:46Z")

</div>

Thanks for responses!

Chris H. wrote:

> why not just have a score column in the answers table?

Yup. So simple solution and it fits just right for my problem. I gotta  
start drawing my models and relations on paper before i start making  
decisions i guess.

Ilan,

You are right if a survey could have multiple anwsers and answer can  
have multiple surveys but that’s not the case. Chris solution fits.
