Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codify a measure in a database field name

I've got a question concerning fields in databases which are measures that might be displayed in different units but are stored only in one, such as "height", for example.

Where should the "pattern unit" be stated?. Of course, in the documentation, etc... But we all know nobody reads the documentation and that self-documented things are preferable.

From a practical point of view, what do you think of coding it in the database field (such as height_cm for example)?.

I find this weird at a first look, but I find it practical to avoid any mistakes when different people deal with the database directly and the "pattern unit" will never change.

What do you think?

like image 862
user15546 Avatar asked Oct 06 '08 13:10

user15546


1 Answers

What's weird about height_cm? Looks good to me.

Sometimes you see measures and units in two separate fields, which is much more painful.

As long as you know the units aren't going to change, I think height_cm is a good way to deal with it.

like image 184
ScottStonehouse Avatar answered Sep 21 '22 23:09

ScottStonehouse