|
|
|
|
|
by ranguna
1585 days ago
|
|
> If I have to invent weirdo gymnastics in my database to enforce something, it's probably best to do in code. What if you had to do weird gynmastcis in the code instead ? Setting up a trigger that checks if the row being inserted has a foreign key that points to a row of another table that has a column with a value that you were expecting. Easily done with a trigger that requires no round trips, but many see it as an overhead because you now need to maintain a function with DB migrations. If you do it in the code, you need to make sure you do a second call to your DB to do this validation everyone you insert in a specific table, something that can be missed when witting code. |
|
The complication is error reporting. Will your application interpret the error that comes from the database correctly? Will your UI (or API) return a useful error?