title: Relational database in ruby on rails
body: <p>I'm making a fantasy soccer team web application to learn how to use ruby on rails and I'm a bit confused regarding how relational databases should work with this sort of example.</p>
  
  <p>I have a table for Users, Players, Teams and My_Team. </p>
  
  <pre><code>class Player &lt; ActiveRecord::Base
      belongs_to :team
      has_one :team
      has_and_belongs_to_many :my_team 
  end
  
  class Team &lt; ActiveRecord::Base
      has_many :players
  end
  
  class MyTeam &lt; ActiveRecord::Base
      belongs_to :user
      has_many :players
  end
  </code></pre>
  
  <p>These are the models I've made. I'm wondering if I need a new class to tie them all together?
  I'm not quite sure how to link them - I haven't made anything requiring a relational database model in a while!</p>
  
  <p>I've successfully displayed all the data, and I have some dummy date in place for players and teams but how should I carry on so that one user has one user team, which has many players?</p>
  
  <p>Is this right?</p>
  
  <p>I'm trying to add a player to someones personal team but I feel like it's not working because of the table design..</p>