Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • Oh, so it's not bad practice to just let it error out? How would I then give a response to the client that the relation is already there? Check if the exception that was thrown is a duplicate key exception and assume it's because I tried to insert a relation which is already there? Commented Oct 30, 2015 at 23:45
  • @Pieter-JanVandenbussche: Yes, you'd get 23505 unique_violation. See error codes. But it should only happen on extremely rare occasions under heavy concurrent write load. Commented Oct 31, 2015 at 1:46
  • Alright, I'll implement that. Thanks for the helpful answers! Commented Oct 31, 2015 at 15:55
  • Exception handling at the DB level is a thing, for sure. Often times the best solution is to let the attempt it, catch the exception, and send back a message accordingly. Commented Nov 1, 2015 at 0:06