> this way i have to implement my businees logic twice. inside the
> database and in the middleware. I dont think that this is very good.
Sometimes implenting the business logic twice is the right thing to
do. For instance, let's say we have a financial application, and we
need to calculate account balances (let's say it's non-trivial to do
this). It seems like it would be good to have the middleware
calculate it, and have PG calculate it. That way, if there is a bug
somewhere in the routine that does the calculation, it will be caught.
It all depends on what you're doing.