Sorry if this question is too silly or neurotic... But I can't figure it out by myself. So I want to see how others deal with it.
My question is:
I want to write a program show progress of do some thing. So I need to record which state is it currently in so that someone can check it by anytime. there are two method:
Use two field to represent the progress state:
step
andis_finished
.Just one filed:
step
. For example, if this thing need 5 step, then6
means finished. ( 0 means not started? )
Compare above two methods.
two field:
Seems more clear. And the most important is that logically speaking
step
andfinished or not
are two concepts? I'm not sure about this.If thing are finished. We change
is_finished
field totrue
( or 1 as you like ). But what to do withstep
field now? Plus one, or just not touch it because it has no meaning any more now?
one field:
- Simple, space saving. But not very intuitive. For example, we don't know what
6
really means by just looking at this field because it may represent finish or middle step. It need other information e.g.total step
to determine. And potentially this meaning is not very stable if the total steps will change (is_finished
field in two field method would not affected by this).
So How do you will deal with it? Thanks!
UPDATE:
I forgot some point maybe useful in the previous post:
The story is: We provide a web-based service for customers. (This service has time limitation e.g. 1 year term) After customer purchase it our deployment programe prepare hardware(virtual machine) and deploy some software which need some time to finish. And we want to provide progress info for customer. When deployment is finished, the customer should be informed.
Database design:
It need a
usage state
field to representrunning normal
,running but owe (expired)
,stop
. What confusing me is should it includenot deployed yet
anddeploying
information or not?The progress info should include some other info e.g. the
start time
so we can tell how much time elapsed since start. But this info is no need to be persistent because we won't care about these info as long as it's finished. So I decide to store these progress info in a separate (temporary) table. Then I think it need another field in another more persistent table to tell if things are done . So can we combine it into theusage state
field mentioned above?