We have a database for an e-commerce application, we are working with JPA 2.0.
We have these three tables: products(id, code, name, description, price); soldproducts(id, quantity, product_id); orders(id, date, status, comment).
Here is our problem: when we delete a product from products table we have a constraint problem in the soldproducts, because the product_id column references a product. We want to delete the product, but we want to have access to the products details.
We want to add an aditional column to the products table, something like availability, which tells us if the product is available or not. With this approach, if we delete a product from the application and the product is not referred from the soldproducts, we are just updating this extra column to unavailable, we don't delete it. Otherwise, we delete the product from the table. But we are not sure if this is the best approach.
What do you think, what is the best design approach for this given situation?