Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List of Best Practice MySQL Data Types

Tags:

sql

mysql

Is there a list of best practice MySQL data types for common applications. For example, the list would contain the best data type and size for id, ip address, email, subject, summary, description content, url, date (timestamp and human readable), geo points, media height, media width, media duration, etc

Thank you!!!

like image 253
Andres Avatar asked Sep 04 '09 16:09

Andres


People also ask

What are the 3 categories of MySQL data types?

In MySQL there are three main data types: string, numeric, and date and time.

What data types are valid in MySQL?

MySQL supports all standard SQL numeric data types which include INTEGER, SMALLINT, DECIMAL, and NUMERIC. It also supports the approximate numeric data types (FLOAT, REAL, and DOUBLE PRECISION). The keyword INT is a synonym for INTEGER, and the keywords DEC and FIXED are synonyms for DECIMAL.


1 Answers

Money: Use the Decimal data type. Based on real-world production scenarios I recommend (19,8).

EDIT: My original recommendation was (19,4); however, I've recently run into a production issue where the client reported that they absolutely needed decimal with a "scale" of "8"; thus "4" wasn't enough and was causing improper tax calculations. I now recommend (19,8) based on a real-world scenario. I would love to hear stories needing a more granular scale.

like image 154
Wil Moore III Avatar answered Nov 08 '22 09:11

Wil Moore III