On Mon, Jan 19, 2009 at 2:23 PM, Bill Moseley <moseley at hank.org> wrote: > In other projects I typically have an "orders" table that lists > individual transactions (purchases, credits, adjustments). That table > also has a column "invoice" so when I want to create an invoice I > would just tally up all the order rows where invoice was null (and set > it to the id of the new invoice). The invoice table was basically just > an id, and timestamp (so it's easy to re-generate any past invoice by > selecting all the transactions with a given invoice id). > > Unfortunately, always seems whatever system I seem to come up with for > a project it doesn't take long before the marketing department comes > up with a new pricing package that isn't supported in the database.... Well, I would not mix the ordering with the "account balance" information. Ordering associates minutes to the account, while the account balance tracks how many minutes are associated with the account and when they expire. Since you can only purchase in blocks, I think simply tracking quantity, purchase date, and expiration date is enough. The application would update expiration date based on business logic. Depending on what these "minutes" really are, you would either deduct from qty when they are used, track usage in a separate table, or both. Thoughts? -- Matt Warden Cincinnati, OH, USA http://mattwarden.com This email proudly and graciously contributes to entropy.