First, you have only one table to handle everything, in order to keep the model design and the data integrity at only one point.
This is the basic idea, you can extend the design with the created_by
& updated_by
columns if you need.
The following implementation is for MySQL, but the idea can be implemented at other kind of SQL databases too.
- Unique key constrain is not possible, but you can create a Trigger to handle it.
- Update many records at same time (
UPDATE ...
) is not possible if you want to save the history. - Delete many records at same time (
DELETE ...
) is not possible if you want to save the history.