Search code examples
c#databasebusiness-logic

Whether to apply business rules on C# code or save in database?


I have developed a E-commerce application which contains complex rules like catalog pricing rules etc. I saved the rules on database. I am confused whether to calculate the rules on code or on database using stored procedures.


Solution

  • Generally I would move logic into the client - databases are the expensive part to scale and them doing less means less licensing if it becomes better, plus the ways to TEST code in the database is harder (unit testing) and slower. I would do calcualtions on the client and store the results. There are (few) exceptions, but that is the general answer.