I need a table that stores items and tracks when an item is…
- queued
- marked for shipping
- shipped
- marked for return
- returned
The table also needs to tell me how many items a customer…
- has received in a month
- has at home at this time
I tried using inheritance. I assigned each step a typeId (from 1 to 5, each id representing the current step in the workflow). This approach is not ideal because updating a workflow step erases history.
For example, if an item moves from shipped (typeId 3) to returned (typeId 5) we lose an accurate count for shipped items.
How should I approach this? Also, I prefer to keep the data in one table unless I get a compelling reason not to.
Update
Items are mailed to customers incrementally. There are limits to how many items a customer can receive within a month period, and limits on how many items a customer can have at home at any given time. For this example, let’s assume 4 for earlier and 2 for the latter. A customers queue can have any number of items. For this reason, items in the queue need to be ranked so the order of items sent can be according to the customers preference.
Items that have shipped already will need to fall out of ranking (the customer can no longer modify rank after an item is sent).
No inheritance here. Time fields are actually date-time. A row is entered into the
Trackingtable when a customer adds an item to the queue. Other time columns fromTimeMarkedShiptoTimeReturnedareNULLuntil the action happens. TheTimeQueuedis part of the primary key in order to allow a customer to rent an item more than once (sounds like video rentals to me).To count items that a customer has at home you could use something like