Som Im trying to design an e-commerce system where vendor is able to add a product to be displayed on the site. The vendor can edit/update the product details, but they should not go “live” until and unless an admin reviews it.
I have several models that represent different products. Here is the design for one such product, but this same system will be applied to every product type.
Here is the diagram:
Can I get some feedback on the pros and cons of this approach.
Is there a better approach to solving this problem.
Is this scalable?
Thanks
What is in the
is_current_productsandawaiting_approvalstables should be stored as a column and not a separate table.Since current products will be queried a lot (each time a customer visits the site), it would be a big overhead to first fetch the
is_current_productstable then display the results fromproducts. It will be an even bigger headache when you want to sort theproductstable.How I would design this is have two tables:
productsandproduct_versions, whereproductsrepresent all the approved information, andproduct_versionsrepresent all the information regardless whether they are approved or historical.Rough schema:
To display current product information, accessing the
productstable is sufficient.To fetch the versions pending approval, just fetch all the ProductVersion where the approved_by or approved_on attribute is null.
To approve a version,
approved_by and approved_on will be changed on product_version, and information of product is changed to the current version, including current_version_id.
With this design, you can also revert to a older version while keeping all other versions in tact.
Hope this helps.