How To Save Relation Column Data After Deleting /ClearingCart Data

So I’m almost done with my app but I have an issue I’m trying to solve. This issue is saving a relation data after the data it’s connected to is deleted.

Here what I’m trying to do. After a user adds a product or products to the bag/cart, then after heading to checkout they would choose they would them confirm payment. After the submit button is hit, I had it set where the bag column’s items/reference would be deleted to clear the cart. This cause an issue.

For my order status table this would remove the relation to the product and other additional info or the seller. How would I go about keeping the data in the bag column from the user will also deleting it?

I’m not sure I get the full picture of your data structure here. So here are some questions:

  • What fields do you want to keep after the user has purchased?
  • Do the rows need to be deleted to make your flow work or is there an alternative?

The field I wish to delete is the user’s bag/cart. The reason for this is so the cart is cleared.