Reputation: 19
I have mysql table for car's accessories like "airconditioner, park assist, cd player, brake assist" and etc. All of them are in INT(11)
. But I am using them like 1
, if the car has this one, or NULL
, if it hasn't. Should I change this INT(11)
with something other? If I can, please tell me how?
Upvotes: 0
Views: 46
Reputation: 108641
You'll save a little disk space on your database server by making this change. You don't need to change your application logic at all; both TINYINT
and INT
are integers you can compare to 1 or 0.
Note that MySQL ignores the 11
in INT(11)
and the 1
in TINYINT(1)
. INT
values are 32-bit numbers, and TINYINT
values are 8-bit numbers.
Unless you have millions of rows in the table, making this change will probably save you only a tiny amount of space. It's already cost you more in your time to ask this question than it will save over a decade of running this database.
Upvotes: 1
Reputation: 1272
What you're doing is creating flags to indicate yes or no values, so that is more suitable for a boolean data type, you can learn how to use boolean values in MySQL from this post.
Upvotes: 0