TinyInt or Char(1)?

R

Ronald S. Cook

In a database table we will have a column "Round" for which round of feeding
the record applies to at a cattle ranch. The value will always be either
1, 2, or 3 since we feed just that many times per day (kind of like
breakfast, lunch, and dinner).

In the table, would you make the column "Round" a TinyInt data type, or a
char(1)? I've heard that you shouldn't use Int unless there might ever be
some sort of math involved, but I'm not sure. I'm just loooking for the
"best practice" if there is one to apply to all such situations.

Thanks,
Ron Cook
 
M

Michael D. Ober

I would use int and then create an enum representing each valid value.
Reference the enum in your code.

Mike Ober.
 
M

Michael D. Ober

Can you give an example of using a byte as the underlying type of the enum?
I just need the syntax as I wasn't aware this could be done.

Thanks
Mike Ober.
 
J

Jon Skeet [C# MVP]

Michael D. Ober said:
Can you give an example of using a byte as the underlying type of the enum?
I just need the syntax as I wasn't aware this could be done.

public enum MyEnum : byte
{
FirstValue,
SecondValue
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top