# Multiple Join Tables between Two Tables? Another solution?

**URL:** <https://www.ruby-forum.com/t/multiple-join-tables-between-two-tables-another-solution/107734>\
**Category:** Rails\
**Created:** [June 25, 2007, 8:36pm UTC](https://www.ruby-forum.com/t/multiple-join-tables-between-two-tables-another-solution/107734 "2007-06-25T20:36:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rcgann](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ed655f/32.png) [@rcgann](https://www.ruby-forum.com/u/rcgann)\
**Post date:** [June 25, 2007, 8:36pm UTC](https://www.ruby-forum.com/t/multiple-join-tables-between-two-tables-another-solution/107734/1 "2007-06-25T20:36:24Z")

</div>

I’m a RoR newbie, so I’d like to be sure I’m on the right track. I’m  
coding an application where I have one table with students and another  
table with first year seminars (fyss). The students have listed 4 fys  
preferences in order.

Since the FYS seminars are listed in order and we are trying to give  
student their first choices, I cannot use a 1 - n relationship between  
table students and table fyss.

My design uses a models as join tables. It works as follows:

- I have a table students with an id and a name.
- I have a table fyss with an id and a course title.
- I have a table fyschoice1s with an id, a student\_id, and a fys\_id.
- I have a table fyschoice2s with an id, a student\_id, and a fys\_id.
- I have a table fyschoice3s with an id, a student\_id, and a fys\_id.
- I have a table fyschoice4s with an id, a student\_id, and a fys\_id.

The last four tables have a 1 - 1 relationship between, for example,  
students and fsychoices1 and between fyss and fyschoices1.

Is this the best solution? I’d deeply appreciate any guidance.  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![rcgann](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ed655f/32.png) [@rcgann](https://www.ruby-forum.com/u/rcgann)\
**Post date:** [June 25, 2007, 8:52pm UTC](https://www.ruby-forum.com/t/multiple-join-tables-between-two-tables-another-solution/107734/2 "2007-06-25T20:52:28Z")

</div>

I would recommend against having 4 tables for joins. Just have  
one :through association with a model that has acts\_as\_list to order  
them.

Michael

---

<div class="post-metadata">

**Author:** ![rcgann](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ed655f/32.png) [@rcgann](https://www.ruby-forum.com/u/rcgann)\
**Post date:** [June 25, 2007, 9:11pm UTC](https://www.ruby-forum.com/t/multiple-join-tables-between-two-tables-another-solution/107734/3 "2007-06-25T21:11:30Z")

</div>

Thanks! I’ve been using Agile Web D. for Rails as a reference.  
My  
solution was inspired by a section entitled Using Models as Join Tables.  
I  
had noticed that the :through option was mentioned on the next page, but  
did  
not see how to use that.

I’ll give it a try. Thanks again! Having four join tables just did not  
seem right.
