title: Which is the good way to link two resources in rest apis
body: <p>Now, I'm starting to develop my web apis using expressjs.
  I'm considering which is the good way to link two resources (two resource already exist in the database).</p>
  
  <p>For example, I have two entities: <code>company</code> and <code>user</code>.
  The relationship between <code>company</code> &amp; <code>user</code> is one to many.</p>
  
  <p>So, the user entity should contains the company_id.
  There are some ways to link a user to a company.</p>
  
  <p>Case 1:</p>
  
  <pre><code>PUT /users/{user_id}
  
  Request: 
  {
    "company_id": "abc"
  }
  </code></pre>
  
  <p>Case 2:</p>
  
  <pre><code>PUT /company/{company_id}/users/{user_id}
  </code></pre>
  
  <p>I prefer with case 1 because in the future when relationships grow such as <code>deparment</code> &amp; <code>user</code>, I don't need to expand my url to support these cases. But I don't know whether it is following the best practices of designing a restful apis or not.</p>