MySQL database design best practices for INTEGER types and integer Best Practices
List of storage space and value ranges occupied by various INTEGER MySQL types
Best practices
- UNSIGNED can only store non-negative integers
- SIGNED can store positive integers, 0, and negative integers.
- The best practice for storing positive integers (such as primary keys) is UNSIGNED, because it occupies the same storage space as SIGNED, but the value range is doubled.
- BOOL and BOOLEAN are just another way of writing TINYINT (1 ).
- The storage space occupied by TINYINT (1), BOOL, and BOOLEAN is the same as that occupied by TINYINT. It is a byte instead of a bit.
- The range of values that TINYINT (1) can store is the same as that of TINYINT. values range from-128 to 127.
- TINYINT (1) is only output as a single bit during display.
References
- Http://dev.mysql.com/doc/refman/5.6/en/integer-types.html
- Http://stackoverflow.com/questions/4401673/mysql-boolean-tinyint1-holds-values-up-to-127
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.