3 ms·
This is a good principle to aim for but it is impossible to fulfill in many cases. There are always going to be invariants that the application may wish to enfo
by libraryofbabel 6y ago
This is a good principle to aim for but it is impossible to fulfill in many cases. There are always going to be invariants that the application may wish to enforce which cannot be enforced in the database (or, if there was some ideal schema to enforce them, the migration from the existing schema would be enormously costly). This is the whole reason we have ACID transactions in relational databases - so the application can enforce its invariants!
(Exercise for the readers: construct a set of invariants that cannot be enforced within a database schema.)
- Silhouette 6y agoThis is a good principle to aim for but it is impossible to fulfill in many cases. There are always going to be invariants that the application may wish to enforce which cannot be enforced in the database As HN doesn't show moderations, I will just say that this is exactly the point I would have made if I'd been replying first. Relational databases are good at enforcing the kinds of relations provided by basic set manipulations. If you try really hard, you can encode some more complicated constraints, but as the complexity increases it becomes unwieldy and eventually impractical to enforce everything at schema level. Edit: Changed "database level" to "schema level" to clarify that I'm not talking about stored procedures here.