Database adapters

Rosa Santiago
A Developers Story </>
2 min readJul 23, 2017

Introduction to PostgreSQL NUMERIC data type.

There are many different data types that need to be met when creating a database in Postgres. One specific data type I would like to cover is the Numeric data type. As a newbie you will need to understand the various types of Numeric inputs. In order to get familiar with these types you will need a better understanding of which term to use when your creating your database. One mistake I came across was the use of decimal.

The Numeric types used are: Integers, Floats and Decimals.

Integers:

Only use if Whole numbers are involved.

This is can be pretty straight forward when qty’s are involved is you are creating a store/product database.

Float:

Decimal numbers stored with floating point precision

Precision is fixed, which can be problematic for some calculations; generally no good for math operations due to inaccurate rounding.In particular, they have problems with decimal fractions

Decimal:

Decimal numbers stored with precision that varies according to what is needed by your calculations; use this best use for math that needs to be accurate

Should be written as :

  :decimal, precision: 9, scale: 2

In this example Precision is the total number of digits, scale is the number of digits after the decimal.

--

--