Good day :)
There is some database in which there are two tables: employee and department . The employee table stores information about the employee, which is logical, and the department table, in addition to the heap of fields, contains a field that indicates the number of employees of a department. The task is to write a trigger that makes a change in the "Number of employees" field after adding a new employee to the "Employees" table. In short, then: added employee, using a trigger, increase by 1 the number of employees in another table . And there was such a nuance, if initially the tables are not consistent ( in the “Employees” table 20 people from department X, and in the “Department” table in the field, the number of employees is all, for example, 6 ), then how to reconcile the tables using the stored procedure ? Otherwise, the triggers do not make sense, your cap.
Thanks for attention :)