I'm working on a database for a friend's growing trucking company. I need to generate a 'manifest' number, thinking the format 'YYMMDD'+UNIQUE (YearYearMonthMonthDayDay+Unique 3 digits) is sensible. I'm wondering what's a good way to get the next manifest number.
* Ok, need to set up a new run on a given date. There are 0 or more manifests already for that date.
* I don't want to just assume anything. But is a 'count' of current records in 'manifest_ids' with date = <what i'm working on> a good idea? I don't think so, since I could delete a manifest in the middle, and the count could make a new manifest number on top of an existing one that was after the deleted one.
* So, take a text (unless there's leading zeroes in integers), say '020804001', and get the next available manifest number ('020804002' maybe, or maybe not ;-)).
I currently have some kludge that puts arbitrary values for each client, and each truck, to make unique values on each date. I need to get away from that though (you can imagine the aggravation as we scale up, keeping track of what's what). Or maybe it's a better way to base it on the client's unique ID?
Sorry if scatter-brained. If you have any suggestions, I'm all ears!
----
JBR
* Ok, need to set up a new run on a given date. There are 0 or more manifests already for that date.
* I don't want to just assume anything. But is a 'count' of current records in 'manifest_ids' with date = <what i'm working on> a good idea? I don't think so, since I could delete a manifest in the middle, and the count could make a new manifest number on top of an existing one that was after the deleted one.
* So, take a text (unless there's leading zeroes in integers), say '020804001', and get the next available manifest number ('020804002' maybe, or maybe not ;-)).
I currently have some kludge that puts arbitrary values for each client, and each truck, to make unique values on each date. I need to get away from that though (you can imagine the aggravation as we scale up, keeping track of what's what). Or maybe it's a better way to base it on the client's unique ID?
Sorry if scatter-brained. If you have any suggestions, I'm all ears!
----
JBR