title: How rails ActiveRecord or Nosql ORM like mongoid handle has_many, has_one side of the relationship?
body: <p>Lets Say I have User and a Team model.</p>
  <pre><code>    class User
        #some fields
        has_one :team
      end
  
      class Team
         #some fields
         belongs_to :user
      end
  </code></pre>
  <p>Now when i do <code>User.last.update(team: Team.last)</code>, it stores user_id: foreign key in team  document. Prety common stuff.</p>
  <p>I want to know what ORMs do/store on the has_one/has_many models(User) just like they store foreign_key on belongs_to(Team) model so that <code>User.last.team </code>query actually gives me a team. Does it create instance methods on <code>User</code> model like</p>
  <pre><code>  def team
      Team.where(user_id: self.id).first
    end
  </code></pre>
  <p>Am I wrong?</p>