News for hackers. Stuff that matters.
Re:The database ruins all good ideas by lmm on Sunday July 18, 2021 @09:15AM (#27872654)
> Why would you be input data in a way that violates referential integrity? That would be pretty bizarre.

Well if you can't get input that violates that integrity then what are you gaining by enforcing that integrity?

> That being said, if your code doesn't catch and handle errors, then there's a couple of deeper problems already.

Sure, but how can you do error handling without data storage, given that your application itself is stateless? Maybe you retry the failure a few times, but ultimately your only option is to drop the data on the floor, which is almost always not what you want.

Re:The database ruins all good ideas by kayodelycaon on Sunday July 18, 2021 @09:29AM (#27872742)
If you allow invalid records and multiple versions of a schema in a collection, you will forever being paying for that mistake every time you read from the database.
Re:The database ruins all good ideas by lmm on Sunday July 18, 2021 @09:08PM (#27878210)
If you're fine with just dropping that invalid data, you can always just delete it at any point in the future. (Yes, that should horrify you - but so should the idea of just erroring and dropping it when someone first tried to write it, which is what an RDBMS would do). The overall effect is the same either way.

Fixing up data that was written wrongly takes work, there's no getting away from that. But if you have a record of the original write attempt then at least you can do that work and recover the data (if you decide the cost/benefit is worth it). Whereas if you have the datastore reject it at write time then you're SOL before you've even started.

Re:The database ruins all good ideas by CRConrad on Wednesday July 21, 2021 @12:30AM (#27902345)
> Yes, that should horrify you - but so should the idea of just erroring and dropping it when someone first tried to write it, which is what an RDBMS would do

Have you ever actually encountered any RDBMS that just silently "drops" your write without informing you, or is this just how you think they work?

Otherwise, isn't this just like any other data write erroring out -- MongoDB driver saying "Service down!", simple flat-file write saying "Disk full!", etc -- in that if your app doesn't react to this, it's not the data store but your code that sucks?

Re:The database ruins all good ideas by justinclift on Sunday July 18, 2021 @12:37PM (#27874298)
> Well if you can't get input that violates that integrity then what are you gaining by enforcing that integrity?

Perhaps I'm wording this badly?

Your application should _not_ be generating data which can't go into the database correctly. If it is, that's a different set of problems. ;)

Re:The database ruins all good ideas by lmm on Sunday July 18, 2021 @09:00PM (#27878174)
What are you claiming the purpose of integrity constraints in the database is? If your application doesn't generate data which can't go in the database correctly, what's the observable difference between a database that enforces constraints and a database that doesn't?
Re:The database ruins all good ideas by CRConrad on Wednesday July 21, 2021 @12:31AM (#27902358)
The difference is that one of them informs you when you've failed at generating valid data to save, and the other doesn't.