Business Logic: Database or Application Layer

前端 未结 24 3228
春和景丽
春和景丽 2020-11-28 02:50

The age old question. Where should you put your business logic, in the database as stored procedures ( or packages ), or in the application/middle tier? And more importantly

24条回答
  •  温柔的废话
    2020-11-28 03:25

    Anything that affects data integrity must be put at the database level. Other things besides the user interface often put data into, update or delete data from the database including imports, mass updates to change a pricing scheme, hot fixes, etc. If you need to ensure the rules are always followed, put the logic in defaults and triggers.

    This is not to say that it isn't a good idea to also have it in the user interface (why bother sending information that the database won't accept), but to ignore these things in the database is to court disaster.

提交回复
热议问题