Often when creating a new web app and configuring MySQL, certain fields will need to change in format as the app develops. For instance, I may change the format of a date field or a field which once was just int now needs a letter or what not. So usually I just make every field Varchar 255 until Im finished at which time Ill change data types to correct ones.
So my question is, how important are data types? Whats the purpose? Speed?
Data types are extremely important – without them, there’s no way to be sure what data is actually stored in the column. For example, a VARCHAR(255) could be anything – string, numeric, date/time… It makes things extremely difficult to find particular data if you can’t guarantee what the data is or any form on consistency.
Which means data typing also provides basic validation – can’t stick letters into a column with a numeric or date/time data type…
The speed of data retrieval is also improved by using indexes on a column, but an index can not be used if you have to change the data type of the data to something else before the data can be compared.
It’s a good thing to realize what the difference is between data, and presentation. Like the case with date field formatting – that’s presentation, which can be easily taken care of if the data type is DATETIME (or converted to DATETIME).