Change report in Database

Asked

Viewed 31 times

0

We have several tables that some users will have permissions for changes. I need to have a table of changes made by the user. Let me give you an example. Let’s assume a products table, this product will be in various establishments with different prices that generates me a products-establishment table right? Now comes my doubt, the user will change the price and I need to store the previous prices, who changed and what was this establishment. It is correct to create a table change and create a relationship with products-establishment?

1 answer

1


The correct thing would be to create a log table, with the primary keys, foreign keys, with the old price, new price and employee code that changed the price. Best practice is to use a trigger that fires every time someone inserts, updates or deletes a price.

  • I get it, just create a log with all the information I need. Just one more question, Only with Trigger and Log can you do this? I like having two options every time. It’s good to have a plan B. kkkkk

  • I believe that the best solution is to do it this way, but you can do it another way yes, you can create a table with the price history of each product. You would have to put all the important information in this table. Ex: COD_PRODUTO, PRECO, DATA_INICIO, DATA_FIM, COD_USUARIO (with the user who changed the information).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.