I have status field that can get some values(not just two) like: pending,active, inactive, inactive by admin, archived.
what mysql field type should I use for performance and readability?
I found two solution. which of these is better and why?(if any other solution let me know):
1- use tinyint and in comment mention that each number is for what
2- use varchar and put status directly into it
My opinion would be that if you are simply selecting
the value then it would not matter whether you will use varchar
or tinyint
.
But if you are going to use it in some where condition then tinyint
would have an edge over varchar
. Also it is recommended to choose the smallest data type possible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With