Hot answers tagged

60

See How much business logic should the database implement? for previous discussion. In general, everyone wants things done in the layer they control. Because then they control it. Every database vendor wants people to put as much logic into the database as possible. Because that locks you into the database. The reasoning is that if multiple ...


16

I am very firmly of the view that when ever possible, business logic should be kept in the software layer and not the database layer. Note, that when ever possible falls far short of always. There are strong arguments for both ways, and as always use engineering good judgement to decide for each project how much weight should be applied to each point before ...


8

Two very important points are missing in your pro-database arguments: performance: database code is executed with direct access to the data, thus avoiding unnecessary transfers (be it across fetching API and mapping schemes on the same machine, or across network for client/server communication) consistency: as several applications may access/update the ...


4

Besides all the facts that have been already pointed out, also remember that having business logic in your code rather that the database eventually turns out to be cheaper. When looking for a developer for an application written in PHP and using MySQL as a database, should your business logic be stored in the database, a simple PHP programmer is not enough, ...


2

The strategy of using shared libraries to solve logic duplication as @Tibo discussed becomes more difficult as client and server platforms diverge. Convenient solutions to avoid complexity or repetition, like sharing a language across a stack or between a client and a server, are ideal at the beginning of a project. Though, in some circumstances, there are ...


1

Previous answers give great reasons to why it's easier/better to put logic in application code vs in a database. One exception I'd like to highlight is when using a big data database/tech stack. In this case, many of the disadvantages go away: You can write unit tests since it's actual code you wrote that sits in the database. You can debug, albeit through ...



Only top voted, non community-wiki answers of a minimum length are eligible