It totally depends on your environment. The answer to the question is really not a coding problem, or even an analysis problem, but a business solution.
If your database supports only one application and is rather rigidly integrated with it, then for reasons of flexibility it is better to put your logic in your application program. In these circumstances, treating a database simply as a simple data repository using common functionality loses little and gains flexibility β with providers, deployment, deployment, and more β and many of the purist arguments that make the crowd of βdata databasesβ defiantly true.
On the other hand, if you are working with a corporate database, which can usually be identified using several access paths, it is very important to secure as much as possible. At the very least, all relevant restrictions should be included, and, if possible, access to data should only be through views and procedures. Whining programmers should be ignored in these cases, because ...
- With a corporate database, an asset is valuable, and invalid data or actions can have business-threatening consequences. Your main concern is to protect the business, not how convenient access is for your coders.
- Such databases, by definition, gain access to several applications. You need to use the abstraction offered by the stored procedures so that the database can be modified when application A is updated and you do not have the resource to update application B.
- In the same way, encapsulating business logic in SP rather than in application code makes it possible to more easily and reliably implement changes in such logic in business than if such logic were embedded in application code. For example, if a tax calculation changes its operation less and more reliable, if the calculation has to be changed in one SP than several applications. The rule of thumb here is that the business rule should be implemented at the closest point to the data, where it is unique - therefore, if you have a specialized application, then the logic for this application can be implemented in this application, but the logic is more widely applicable business should be implemented in a joint venture.
In your case, you have several applications accessing the same database, so you need to move the logic and audit functions from the application level to the database. I myself usually added audit functions to the database itself, because if I was ever asked to investigate the problem of fraud (and this happened more than once), I just feel like I can stand up and be confident in my findings with much more than if if it were at the application level - there are simply fewer opportunities for reservations.
Encoders that plunge into religious wars for using or not SP, as a rule, worked only in one environment or another, so they extrapolate their limited experience to a cast-iron position, which will really be justified and correct in the context from which they come, but miss big picture. As always, you must decide on the needs of the business / customers / users and not what type of coding methodology you prefer.
source share