views:

25

answers:

3

I have an application which has rows of data in a relation database the table needs a status which will always be either

Not Submitted, Awaiting Approval, Approved, Rejected

Now since these will never change I was trying to decide the best way to implement them I can either think of a Status enum with the values and an int assigned where the int is placed into the status column on the table row.

Or a status table that linked to the table and the user select one of these as the current status.

I can't decide which is the better option as I currently have a enum in place with these values for the approval pages to populate the dropdown etc and setup the sql (as it currently using to bool Approved and submitted for approval but this is dirty for various reasons and needs changed).

Wondering what your thought on this were and whether I should go for one or the other.

If it makes any difference I am using Entity framework.

+1  A: 

I would go with the Enum if it never changes since this will be more performant (no join to get the status). Also, it's the simpler solution :).

Goblin
+1  A: 

Now since these will never change...

You can count on this assumption being false, and sooner than you think.

I would use a lookup table. It's far easier to add or change values in a lookup table than to change the definition of an enum.

You can use a natural primary key in the lookup table so you don't need to do a join to get the value. Yes a string takes a bit more space than an integer id, but if your goal is to avoid the join this will accomplish that goal.

Bill Karwin
A: 

I use Enums and use the [Description("asdf")] attribute to bind meaningful sentences or other things that aren't allowed in Enums. Then use the Enum text itself as a value in drop downs and the Description as the visible text.

Chris Marisic