Refactoring with Loops and Collection Pipelines: Grouping flight records
martinfowler.com
martinfowler.com
Working with collections is what it's suited for, so why try to do this anywhere else?
I suppose you could create a database to store the data and then query it, but that might be adding more overall complexity to your system than would be saved by using SQL instead.
To name a few:
[0] Application code is much easier to test. This is by far the biggest factor. I recently rewrote a legacy application that was mostly driven by stored procedures hundreds of lines long, to a service driven application with database interaction limited to lookups and saves. We were able to wrap hundreds of automated tests around that process. The confidence we gained and freedom to improve upon it down the road was unbelievable.
[1] High level application code is much easier to read and understand than really complex SQL; and therefore is much easier to support. This is extremely important when you have a large team of developers. Of course, bad code is bad code, whether it's in the application or database, however I find this rule is still generally true.
[2] Depending on your database vendor, the application layer is usually much cheaper to scale horizontally. In the enterprise, I've worked mostly with SQL Server and there is no comparison in the licensing cost involved in standing up a new database server vs an application server.
Of course, this is not always the case but from my experience this approach has made the most sense.
This doesn't apply to data which is being manipulated before stored, of course.