Posts

Showing posts from 2013

Database Design: How to Decide What Column Types to Use in MySQL Databases

This post is assuming you have already determined your database and tables structure in your MySQL design. The next step would be to specify what types of data, length of the column data, if it can be null, and possibly default values. First, what type of data will this column contain? The three primitive data structures in MySQL are text, number, and date/time. Within the text data type, the subtypes are the following: CHAR(LENGTH) - Fixed-length field from 0 to 255 characters long. VARCHAR(LENGTH) - Variable-length field from 0 to 65,535 characters long.  TINYTEXT - A string with maximum length of 255 characters.  TEXT - A string with maximum length of 65,535 characters long. MEDIUMTEXT - A string with maximum length of 16,777,215 characters long. LONGTEXT  - A string with maximum length of 4,294,967,295 characters long.  Within the number data type, the subtypes are the following: TINYINT(LENGTH) - A number value that goes from -128 to 127 or, if unsigned, 0 to