# Best way to define assocations

**URL:** <https://www.ruby-forum.com/t/best-way-to-define-assocations/146673>\
**Category:** Rails\
**Created:** [August 23, 2008, 10:36pm UTC](https://www.ruby-forum.com/t/best-way-to-define-assocations/146673 "2008-08-23T22:36:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rnew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9dc877/32.png) [@rnew](https://www.ruby-forum.com/u/rnew)\
**Post date:** [August 23, 2008, 10:36pm UTC](https://www.ruby-forum.com/t/best-way-to-define-assocations/146673/1 "2008-08-23T22:36:48Z")

</div>

I think this is an easy question, but i just don’t know the best way to  
do this.

I have the following tables:

- Exercises
- Biking\_details
- Running\_details.

as you can see i have 2 kinds of Excercises: running and biking

so i could do this:

Exercise:  
has\_one :biking\_details  
has\_one :running detail

running\_detail  
belongs\_to :exercise

biking\_detail  
belongs\_to :exercise.

of course this could work, but these models would allow that an exercise  
would have both running and bking details, which is not possible

when i would like to generate a list of exercisess with a column  
“exercise type”, i would have to loop though a the list of exercises and  
for each record check if there is biking detail OR a running detail,  
generating a lot of queries

i could solve this by adding a field exercise\_type to the exercises  
table, but wouldn’t this be kind of redundant?

so now i am having troubles to decide what to do

who can give me some insight?

thanks
