This is a very common thing in web applications. If I have a user table and I want to keep track of all the changes made to the user table, I can use a database insert and update triggers to save those changes in the user\_history table.

But what if I have user\_products table, where I have user\_id , product\_id, cost. When I add a user in the system lets say I have two products associated with that user. So my user\_products table will have two rows for that user. 

```
user_id product_id cost
1       10         1000
2       20         2000

```

Now if I go to the edit user page and delete product 1 , add product 3 , change cost for product 2 from 2000 to 3000. 

so normally I delete all records for user\_id 1 from user\_product table and then do a new insert for the new products. 

So its not a regular update but a delete and then insert. Hence I am not able to keep track of history changes. 

Ideally I would want to know that I deleted product 1 , added product 3 , changed cost for product 2 from 2000 to 3000. 

**EDIT 1:-**

I am not doing a update. I am doing a delete and then insert. So I am deleting record with product id 2 and cost 2000. And then again inserting record with prod id 2 but with cost 3000. So technically its delete and insert but logically only cost is changed from 2000 to 3000. If i check while executing both queries it will say i deleted product with id 2 and and then added product with id 2 which are same. But I want to be able to see that the cost has chnaged from 2000 to 3000