Logic inside the database: procedures and triggers
Sometimes it is not enough just to store data - you need the database to react to changes. For example, it automatically recorded who and when changed the price of a product in an online store, or checked the conditions before saving. To do this, PostgreSQL uses stored functions (and procedures in the broad sense) and triggers: the code is executed next to the data, without additional round-trip into the application.