I have a 3-tiered web application with a web view layer, a business logic layer, and a database persistence layer. I am adding a feature that populates a history table with records if and only if the element being saved has changed (it compares the previous and current records and saves the history records if anything has changed).
I'm not sure if the logic of building the history records and saving them belongs in the business logic layer or the database persistence layer. The database persistence layer has a single saveElement method. The business logic layer has multiple places that call the database persistence's saveElement method.
Advantage of placing the history logic in the database persistence layer:
-If the logic were placed in the business logic layer, there is a risk that some of the business logic layer callers would forget to call the method to create the history records. If the logic was placed in the database persistence layer, any saved record is guaranteed to have a history record created.
-The site has another history system for other information that is in the database layer and it would create consistency if both systems were located in the same place.
Advantage of placing the history logic in the business logic layer:
-There is a bit of complexity in building the history records and the database layer is mainly used for calling/running sql queries.
So is there any compelling reason to place this logic in either the business logic layer or the database layer? Or does it not matter where the logic is placed?