2 ms·
As someone who hardly ever uses a RDBMS (I'm in QA and most of my "work coding" is test automation and/or tool work), what happens when you try to deal with dat
by Splines 15y ago
As someone who hardly ever uses a RDBMS (I'm in QA and most of my "work coding" is test automation and/or tool work), what happens when you try to deal with data validity constraints? In .NET-land, do you put a try-catch around it and bubble that back up to the user "well, you did something bad, I guess you should double-check what you just entered here"?
- lost-theory 15y agoIf you put your constraints in the database schema, then you check for errors on insert/update/etc., like you said, with try-catch. If you put your constraints in the application code, you usually have some validation layer that the data passes through before sending it to the DB. It's common to have validation live both in the DB and in the app code. The constraints in the app code are for catching and displaying errors up front and display them to the user (e.g. on a form), while the DB constraints are used as a last line of defense to ensure data integrity.