E
E
Ektomorphine2017-04-27 02:37:39
css
Ektomorphine, 2017-04-27 02:37:39

How to check the consistency of tables using a stored procedure?

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 in the department table, in addition to a bunch of fields, there is a field that indicates the number of employees in 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 an employee, use a trigger to increase the number of employees in another table by 1 .
And there was such a nuance if the tables were initially inconsistent (in the table "Employees" there are 20 people from department X, and in the table "Department" in the field the number of employees in total, for example, 6 ), then how, using a stored procedure, to coordinate the tables? Otherwise, triggers have no meaning, your Cap.
Thank you for your attention :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
entermix, 2017-04-27
@entermix

1. Write a trigger, run, check
2. Write a procedure that will reset the counters and correctly fill them in, execute it
3. Ptofit

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question