Edward Posted September 24, 2012 Share Posted September 24, 2012 I have a status value which i need to store in my database, either a 0 or 1, could anyone suggest the best data type for this with some reason. I noticed boolean would that be a good choice if not why? Link to comment Share on other sites More sharing options...
Edward Posted September 25, 2012 Author Share Posted September 25, 2012 Well after saving my data as Boolean the value in MySQL actually showed as a tinyint(1), well unless any of you suggest something better i see no reason in not going with that. Link to comment Share on other sites More sharing options...
Larry Posted September 25, 2012 Share Posted September 25, 2012 Yeah, so MySQL doesn't actually have a Boolean type, it just uses 1/0 internally. That's the argument against using Boolean. 1 Link to comment Share on other sites More sharing options...
Edward Posted September 26, 2012 Author Share Posted September 26, 2012 I guess is doesn't but i found BOOLEAN in a drop down list when i was adding a new column to one of my tables in PhpMyAdmin, but after the column was created it showed tinyint(1) as i earlier stated. Link to comment Share on other sites More sharing options...
Larry Posted September 26, 2012 Share Posted September 26, 2012 MySQL will change column definitions to be what it considers more optimal, too. Link to comment Share on other sites More sharing options...
margaux Posted September 26, 2012 Share Posted September 26, 2012 I like using the enum type, which is very simple and best used when you are certain additional values will not be required. Would you say this field type is a good performer? Link to comment Share on other sites More sharing options...
Larry Posted September 26, 2012 Share Posted September 26, 2012 I can't speak to its performance, although internally MySQL stores ENUMs as TINYINTs, too. Link to comment Share on other sites More sharing options...
Edward Posted September 26, 2012 Author Share Posted September 26, 2012 Well these systems now can handle millions of records with no bother as you did state before, so if its something that is perform related we can worry about that if our sites are ever to become that busy, which looks highly unlikely with all the competition out there. Anyway there is no harm in trying, gives us something to keep us busy. Link to comment Share on other sites More sharing options...
Recommended Posts