|
Group: Forum Members
Posts: 2K,
Visits: 6.6K
|
I'd consider using a sproc in the database if there was a lot of data access requirements and you really needed the speed. However, even if you do this, you likely will need to have code that calls the sproc somewhere anyway...back to the same question. Also, if you use the FillMultipleDataTables static method of BusinessLayer you can actually get data from multiple BOs with one trip to db, so that would be fast. The other issues I've had when putting business logic in the database are:
- the business logic is now distributed between tiers, which makes it harder to maintain. There are good cases for doing this (see below), but I'm a bit more careful now about when I do this. - Typically it can be harder to update the database than to update the application. The DDT helps a lot, but my preference is to minimize updates to the database if I can help it. Since this is business logic and could change, I'd tend to put it into the app. Also, you might find that this changes a lot and you actually need to drive the logic via something like a configuration file or meta data in the database, in which case, it is typically much easier to implement in the application.
The other side is speed. If you need speed, then the database is often the way to go. This is especially true for complicated reporting needs or algorithms that need lots of data access. E.g. if you had to get data from table 1, check if X is true for every column, grab data from Table 2, otherwise grab data table 3, then build a temp table to do an intermediary calculation, lookup data Table 4, etc... then it is way more efficient to do it at the server. With CLR sprocs, you can now handle really complicated logic and have speed too.
|