U
U
user_of_toster2021-03-18 10:36:13
Software design
user_of_toster, 2021-03-18 10:36:13

Are DB triggers smearing business logic?

Let's take the task of counting likes. Each like creates an entry in the database. In order not to use count(*), it was decided to denormalize the database and make another table post-number of likes.

Obviously, after each like, you need to update the counter. This can be done in two ways.

1) Database triggers
2) In the business logic layer, directly write a query to the database.

Question - do I understand correctly that, from an architectural point of view, triggers will smear business logic with a database-access layer?

Can we say that database triggers are an antipattern?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2021-03-18
@user_of_toster

It is impossible to unambiguously say that "database triggers are an antipattern". It depends on what exactly the trigger does, but in this case, yes, it blurs the logic between different layers.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question