smallest mysql type that accomodates single decimal

Posted by donpal on Stack Overflow See other posts from Stack Overflow or by donpal
Published on 2010-04-25T11:22:29Z Indexed on 2010/04/25 11:23 UTC
Read the original article Hit count: 297

Database newbie here. I'm setting up a mysql table. One of the fields will accept a value in increment of a 0.5. e.g. 0.5, 1.0, 1.5, 2.0, .... 200.5, etc.

I've tried int but it doesn't capture the decimals.

`value` int(10), 

What would be the smallest type that can accommodate this value, considering it's only a single decimal.

I also was considering that because the decimal will always be 0.5 if at all, I could store it in a separate boolean field? So I would have 2 fields instead. Is this a stupid or somewhat over complicated idea? I don't know if it really saves me any memory, and it might get slower now that I'm accessing 2 fields instead of 1

`value` int(10), 
`half` bool,  //or something similar to boolean

What are your suggestions guys? Is the first option better, and what's the smallest data type in that case that would get me the 0.5?

© Stack Overflow or respective owner

Related posts about database

Related posts about mysql