title: Ruby on Rails - Model Relations
body: <p>Im working on a little app for Ruby on Rails and Ive got a question regarding the relationship between models.</p>
  
  <p>I have "Teams" which play against each other in "Matches"</p>
  
  <p>The tables currently look like this although I might have to make some changes to the matches table.</p>
  
  <p>Teams:</p>
  
  <pre><code> id   | Name
   1    | some-name#1
   2    | some-name#2   
   3    | some-name#3
  </code></pre>
  
  <p>Matches</p>
  
  <pre><code>id   | team_id1 | team_id2 | result1 | result2
   1   |     2    |    3     |    -1   |   -1
  </code></pre>
  
  <p>In this example the team with id 2 plays against team with id 3. The result is not yet entered and therefore set to "-1" for both. If Team 2 would loose against Team 3 with a score of "3:7" then result1 would be "3" and result2 "7"</p>
  
  <p>A Team has many matches and one match belongs to two teams.</p>
  
  <p>How can i model the relationships in Rails?</p>