The restriction of business logic at the application level is at best shortsighted. Experienced professional database designers rarely allow them in their systems. A database should have restrictions and triggers and stored procedures to help determine how data from any source will enter it.
If the database must maintain its integrity and ensure that all sources of new data or data changes follow the rules, the database is the place to put the required logic. Putting it on the application layer is a data nightmare awaiting its appearance. Databases do not receive information from only one application. The business logic in the application is often inadvertently bypassed by import (it is assumed that you have a new client who wants the old historical data to be imported into your system or a large number of target records, no one is going to enter a million possible goals through the interface, this will happen during import .) It also bypasses the changes made in the request window in order to fix one-time problems (for example, increasing the price of all products by 10%). If you have application-level logic that should have been applied to data modification, this will not happen. Now it’s normal to put it in the application layer, and there’s no point in sending bad data to the database and wasting the network on network bandwidth, but in order not to get into the database, sooner or later there will be data problems.
Another reason to save all this in the database is related to the possibility of fraud by users. If you put all your logic in the application layer, you must give users direct access to the tables. If you encapsulate all your logic in stored procs, you can limit them only to what stored procs allow, and not something else. I would not allow any user to have access to a database in which financial records or personal information (for example, health records) are stored, since I do not allow anyone but a couple of dbas to directly access production records in any form or form More fraud is committed than many developers implement, and almost none of them are considering developing them.
If you need to import a large amount of data, going through the data access layer can slow down the import bypass, because it does not benefit from set-based operations that are designed to process databases.
HLGEM Sep 24 '09 at 20:15 2009-09-24 20:15
source share