which will be the best approach for a table design for keeping statuses for a product:
- Product Accepted
- Product Declined
- Product Finished (Shipped)
These are my ideas:
-
a int field for “accepted” another for “declined” and another for “finished” (with values 0 or 1)
-
a datetime for each “accepted”, “declined” and “finished” (by default the field will be NULL)
-
just a field “status” with values 1, 2 or 3.
If the status can only be one of those three at any time, then there should only be one field. So, your third idea would be correct. Having three fields when only one is necessary would be a waste of storage space, so should be avoided.
The best solution is to simply have a
statusfield that holds which one of the three statuses the product is at. This will also make adding or removing a status easy since you will only have to modify the code to insert a different value, not the database itself.If you do need the date at which the status was last changed to also be stored, you could have a field called
last_status_changewhich is a datetime and you update to the current time whenever you change the status.