Say my database tables have columns like UserType, SalesType, etc.
Should I have database tables with UserTypeID, userTypeName or should I just create a C# enumeration?
Say my database tables have columns like UserType, SalesType, etc.
Should I have database tables with UserTypeID, userTypeName or should I just create a C# enumeration?
What's wrong with both? If value's are user-defined or changing, definitely enum
will not be suitable.
If values are strictly non-changing (such as gender), you can have them as enums
for ease of reference in the application and also in the DB as separate table to enforce foreign keys and as a reference.
If list is stable enough to use an enum, then I would use an enum in you code plus a table in the db (make it a foreign key for data consistancy)
It depends. I listed a few pros and cons for each approach below. In general, I strongly prefer enums if the application needs to use a value to make decisions. As Mehdrad mentioned, you can use both approaches but it requires extra effort to keep the lists in sync.
Lookup tables:
Enum: