Database adapters

Rosa Santiago
Jul 23, 2017 · 2 min read

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.

A Developers Story </>

developers story

Rosa Santiago

Written by

Techie. Foodie. Wanderlust.

A Developers Story </>

developers story

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade