Setup DB for when a product is on sale What would you do to handle products and when these products have a sale?
Should I add a field to Product to indicate a sale or should Sales be a different model and use it with like a one to many relationship?
One Sale has Many Products
One Product has One Sale
Just flag products on sale via a boolean field and perhaps an extra field for amount off. Record any sales normally with sale price.
Depending on how complex, you may need a related table to track what percent something is marked down.
But I try to keep as simple as possible.
Example: widget for a week is 50% off, ok for that week sell them record the invoices, etc.
But somewhere, have the boolean to change to now not on sale.
@jlrdw I did it that way for another online store I did it had a discount field that was a %, when empty it's not on sale. I was just wondering if that was the best way.
It's one way. But really the best way, that can be a very subjective.
Please sign in or create an account to participate in this conversation.