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. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Michael Latta
2007-Jun-25 18:51 UTC
Re: Multiple Join Tables between Two Tables? Another solution?
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 On Jun 25, 2007, at 11:34 AM, rcgann wrote:> > 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. > > > --~--~---------~--~----~------------~-------~--~----~ > You received this message because you are subscribed to the Google > Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk- > unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > For more options, visit this group at http://groups.google.com/ > group/rubyonrails-talk?hl=en > -~----------~----~----~----~------~----~------~--~--- >
Robert Gann
2007-Jun-25 19:10 UTC
Re: Multiple Join Tables between Two Tables? Another solution?
Thanks! I''ve been using Agile Web Development 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. On 6/25/07, Michael Latta <lattam-ee4meeAH724@public.gmane.org> wrote:> > 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 > > > > On Jun 25, 2007, at 11:34 AM, rcgann wrote: > > > > > 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. > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---