Put business logic in the application, not the database
We’ve all done it. We needed to pull data out of an SQL database, and the query we needed to pull out data was a complex query with multiple table joins, complex filter criteria, and sophisticated WHERE clauses.And why not? SQL databases such as MySQL and PostgreSQL are really good at performing complex joins, filtering, and sorting in order to get exactly the data you need out of a query and nothing more. Let the database do the work! It sure is a lot easier than having to write that logic in the application code, right?Wrong. [ Also on InfoWorld: How to choose a cloud database ] By performing these operations inside the database, what you are really doing is pushing application business logic down into the bowels of your database. You are taking this business logic out of your application code, and moving it into database logic instead.To read this article in full, please click here
We’ve all done it. We needed to pull data out of an SQL database, and the query we needed to pull out data was a complex query with multiple table joins, complex filter criteria, and sophisticated WHERE
clauses.
And why not? SQL databases such as MySQL and PostgreSQL are really good at performing complex joins, filtering, and sorting in order to get exactly the data you need out of a query and nothing more. Let the database do the work! It sure is a lot easier than having to write that logic in the application code, right?
Wrong.
By performing these operations inside the database, what you are really doing is pushing application business logic down into the bowels of your database. You are taking this business logic out of your application code, and moving it into database logic instead.