maintain history in a database

后端 未结 5 1857
余生分开走
余生分开走 2020-12-15 00:37

I am designing this database that must maintain a history of employee salary and the movements within the organization. Basically, my design has 3 tables (I mean, there more

5条回答
  •  我在风中等你
    2020-12-15 01:20

    Triggers will likely be faster, and don't require a "middle man" to get the job done, eliminating at least one chance for errors.

    Depending on your database of choice, you can just use one table and enable OID's on it, and add two more columns, "flag" and "previous". Never update this table, only insert. Add a trigger so that when a row is added for employee #id, set all records with employee #id to have a flag of "old" and set the new rows "previous" value to the previous row.

提交回复
热议问题