3 ms·
Like everything, it depends. Some business logic like "this field should never be negative" is probably fine. More complex logic is a lot harder to maintain.
by jayd16 5y ago
Like everything, it depends. Some business logic like "this field should never be negative" is probably fine.
More complex logic is a lot harder to maintain. You don't want to stress your DB's CPU if you can avoid it. You still need some kind of connection pooler anyway. There's a lot of reasons it doesn't make sense to put all your business logic in the DB. SQL is not the easiest language to maintain (not enough abstraction).
IMO the line to draw is just enough to keep data sanity.
- aww_dang 5y agoValidation on the client, for user convenience. Validation on the backend, for security. Validation on the DB, for sanity. Error states are a bit funky if you don't validate in the backend logic.