4 ms·
It seems the constraints are mainly useful while developing. You probably never should hit constraints in a production system.
by maxxxxx 9y ago
It seems the constraints are mainly useful while developing. You probably never should hit constraints in a production system.
- justherefortart 9y agoNah, have them at every level. Javascript, server side code, then business layer code, then data layer (why not, we're doing in the DB as well), then in the db itself. Laughable.
- maxxxxx 9y agoWhat's laughable here?
- jimktrains2 9y agoWhy laughable? Different levels can support different amounts of context in logging and error handing and ultimately the message the end user sees.
- SigmundA 9y agoWhy is defense in depth a laughable concept?
- GiorgioG 9y agoConstraints are useful when people are trying to manipulate the data outside the bounds of your application. Think ETL, “fixing” data, etc.
- acdha 9y agoAlso plain bugs. If your database changes less rapidly than the client code it’s a great way to avoid simple mistakes taking a ton of work to repair. This is especially important if you have a large team and your best developers don’t work on the “boring” parts.
- anarazel 9y agoWith concurrency it's certainly reasonable to hit constraints in production. Another session deletes something, another inserts a row that attempt to reference the deleted row. Or you have multiple users registering with the same account name at the same time. Etc.
- maxxxxx 9y agoThat makes sense. I guess most of the stuff I do doesn't do much concurrent database access.
- semiquaver 9y agoYou might think that, but the most common cause of constraint violation in the web-programming world is unintentional user double clicks setting up a race between simultaneous requests.
- Something1234 9y agoCause they get frustrated when your app isn't fast or responsive enough.
- vbsteven 9y agoYou would be surprised to see how many (often older) people double click everything by default. Explorer folders, desktop shortcuts, web forms, it is all the same to them. I’ve run a number of event sites for luxury car brands and it was stunning how many double-click form submissions we received on those. Often just milliseconds apart.
- maxxxxx 9y agoIt's not only old.people who do the double click thing. I see the same with a lot of our sales reps when I watch them use our stuff.
- daveFNbuck 9y ago
- DrScump 9y agoEven if there is perfect enforcement of constraint criteria at deployment, code has been known to be changed after deployment. Sometimes.