2 ms·
Right, but the point is that by moving it to the database level, you give the applications above it some guarantees about the state of the DB. You can be sure
by nostrademons 10y ago
Right, but the point is that by moving it to the database level, you give the applications above it some guarantees about the state of the DB. You can be sure that some other application hasn't gone and written to the DB without firing the trigger. You can be sure that you don't get race conditions from an application not properly using transactions when updating the derived data. And you can be sure that if a transaction is rolled back, the derived fields will still be in a consistent state.
It doesn't free you from programming, from reasoning about your code, or from ensuring that this code is free of bugs. But it does free you from worrying about whether the bugs exist in multiple places or whether there are subtle race conditions involved in the code interacting with itself.
Whether this important depends on how many applications are accessing the same database. There's a strong argument for one app = one DB, if you can get away with it, and then none of this is relevant. This is not always possible.
- Roboprog 10y agoOther application? There is no other application, old man. What you talkin' 'bout? ... (2 years later) ... Oh, now I get it!