Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

whats the best datatype to store height?

Pretty straight forward question, I want to store feet and inches in 1 column using a decimal, but I dont want it truncated like how the float type does.

like image 407
Leslie Jones Avatar asked Nov 07 '14 18:11

Leslie Jones


2 Answers

Store all your data in MKS (metric). When presenting and storing convert the data into an international standard. and store it in a decimal type.

Thus if your tool to gather the data is in 6'2" format convert it into cm and save in your data table. Then reverse this for display.

By saving in a standard format decimal cm. finding people with the same range of height is easier, where as if Ft and In are in separate columns ranges are really hard.

like image 136
Stephen Bodine Avatar answered Sep 30 '22 04:09

Stephen Bodine


The imperial unit system still used in Myanmar, Liberia and that one country in North America is unfortunately not very arithmetics-friendly. There is no native data-type to handle the strange base12/base3/base1860 math for it.

You should really use the much more widely-used metric system and use a FLOAT or DECIMAL value representing meters.

However, when you really want to stay with the imperial system, you should store the value in inch and do the conversation to feet + inch on the GUI level.

like image 24
Philipp Avatar answered Sep 30 '22 02:09

Philipp