Answer the question
In order to leave comments, you need to log in
How to design a model so that it is possible to track the change in position?
I have an employee entity. How to provide for the storage of the history of the change of positions by employees? So that you can request, for example, the number of job changes or how many times an employee has been in such and such a position?
Answer the question
In order to leave comments, you need to log in
employees separately, positions separately, the current position of the employee in the table of employees, and a separate table with the history of positions: employee, position, when he joined, when he left the position and who carried out the acceptance / removal from the position
What's stopping you from keeping it that way?
employee
id position id (or write the position directly, does not play a role)
Date of entry into the position
It is possible to hang up tracking of change on the trigger.
Personally, I switched to storing small amounts of hierarchical data in JSON a long time ago. Also hung up on adding/changing triggers. There is a history table where, when the trigger fires, I transfer the old Json data. I do version comparisons only if necessary outside the database. Calculating the difference through the query language is very difficult.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question