DEV Community

Discussion on: Database constraints are (often) harmful

Collapse
 
tsvetanganev profile image
Tsvetan Ganev

Interesting take. I've heard the same arguments about foreign keys being evil because they degraded performance. If we follow this logic, we don't need RDBS at all and all applications should store their data in plain binary files. I agree not all software systems require strong data consistency/integrity but we can't scrap 50 years of DB development so easily. Critical systems that work with money in some form must be modeled strictly on the data layer as well as on the application layer.

Collapse
 
jonlauridsen profile image
Jon Lauridsen • Edited

I see your angle. What I find necessary is to challenge the dogma I sense of always creating constraints. I want to trust the code to handle business requirements and I see no issue joining manually.

I do see where you’re coming from with your financial comment and it could be true: The data storage constraints can act as a kind of extra bookkeeping check, further enhancing correctness on top of test-automation. It's sound logic. But I suspect I’d still want to see how far we can guarantee correctness in the code, with appropriate layers of test automation.