I am creating a table with several fields that will be used to record weight and length.Examples: 5 kilograms and 50 grams will be stored as 5,050.2 meters 25 centimeters will be stored as 2.25.
What T-SQL data type is best for them? Some calculation against these fields will be necessary, but using the default decimal (18.0) seems redundant.
It depends on the range of values ββthat you intend to maintain. You must use a decimal value that covers this range.
, , , . , , 1000 , 7 , 3 - . (7,3)
, . WeightInKilos, LengthInMetres
, . 0,00 1000,00 . , 6 ( = 6), 2 ( = 2). decimal:
weight decimal(6,2)
() float real. , .
float
real
, . , . . .
. harriyott , . - , , )
If these measurements are wide open and generally such that you need to support very large and very small numbers, perhaps the measurement can be divided into two columns. One to hold the value and one to hold the unit. One of the biggest glitches in this would be comparing values ββif you need to find the heaviest objects, etc. This can be done using the lookup table, but, of course, adds a level of complexity.
Source: https://habr.com/ru/post/1722779/More articles:changing the scope of an anonymous function to setTimeout causes a strange warning - javascriptDeclare a variable in another scope - javascriptspecifying the date format when using $ form-> input () in CakePHP - dateTimer for polling services - multithreadingHow can I find the value on the map using binders only - c ++How to determine if the mouse cursor is over a given uielement? - silverlightWhat is the best practice for setting the SccAuxPath property in a Visual Basic.NET project for a distributed command? - version-controlZend Framework: how can I connect to the final presentation of the output before sending it to the browser? - phpunit test method that creates the object - oopmySQL - Should I denormalize? - databaseAll Articles