title: Foreign key constraint in REST API
body: <p>I'm designing RESTful API for trip planner application and don't know how to enforce foreign key constraint on resource creation. I have two resources: <code>Trip</code> and <code>User</code>. <code>Trip</code> resource looks like this:</p>
  
  <pre><code>{
    "id": 1,
    //some other attributes
    "tripParticipants":[ 
      {
        "id": 1
      }
     ]
  }
  </code></pre>
  
  <p>where <code>tripParticipants</code> is collection of <code>User</code> ids. <code>TripParticipants</code> should only contain created <code>Users</code> (by created I mean stored in database).</p>
  
  <p>I have trouble with endpoint <code>POST /trips/{id}/tripParticipants</code> to add elements to the collection. 
  What should I return when <code>User</code> with given id doesn't exist in my database? Returning <code>HTTP 404</code> status code for <code>POST</code> operation looks weird. Does REST standard defines some solutions to this use case?</p>