I am an ASP.NET Developer. I am working on a project where I need to manage Creation, Update and Deletion of records. I need to know what would be the best practice to handle the following issues: - When Inserting a record, there are constraints to prevent insertion 2 items having the same code for example. So what would be the best way to prevent that: Add unique Constraints at the Database level and handle exceptions in my application code? If so, the exception itself is not informative enough unless I dig into the exception message, meaning there is not a unique exception for every different constraint violation. Would it be better if I check in my stored procedures before attempting to insert, and return a flag indicating why an insertion fails?
-When Deleting a record, the same thing concerning Foreign keys, where to handle the violation, on the database or in my application code?