vincent15000's avatar

Best way to work with a table whose content can change ? relationship or not relationship ?

Hello,

Just a question about this situation.

Imagine you have data in the products table.

Today product A exists, tomorrow product A won't exist anymore and there will be new products (B, C, ...).

Product A has been sold to clients, so there is informations about product A on the bill.

Product A is hard deleted in the database, but I need to keep informations about it because it has been sold to clients.

Some CRMs work like this, by hard copying products data to deals rather than using a relationship and soft deletes.

What do you think about this way to do ?

What are the advantages instead of doing with soft deletes and relationships ?

Thanks for your help.

V

0 likes
2 replies
Tray2's avatar
Tray2
Best Answer
Level 73

Use soft deletes that way you will not need to change so much, just a scope on the products page so they don't show up, and the user can still see it from the invoice/order and go to the deleted product.

Another way would be to use a trigger to move the product to a discontinued products table and then have a union of those for the invoices/orders.

I would go with the first, unless we are talking millions of records of both active and discontinued products.

2 likes

Please or to participate in this conversation.