NoSQLBeginner

Which types do you reach for, and which do you avoid?

“Money, timestamps, ids, enums — what types and why?”

What this tests

  • Type discipline

Answers by level

Read the beginner answer first and notice what is missing.

numeric for money, never float — float cannot represent 0.10 exactly. timestamptz for every point in time, never plain timestamp. bigint for ids and counts, not int (2.1 billion ceiling). text, not varchar(n). boolean, not char(1). uuid when ids must be generated without coordination.

Green flags · Red flags

Strong green flag · Explains why float money is a bug.
Green flags
  • numeric for money, timestamptz for time, bigint for ids
  • Reasons, not just names
Red flags
  • float for money
  • timestamp without time zone
  • int for a large key

Follow-up questions

F1
Why timestamptz over timestamp?

Scenario

A billing table stores amounts as float and totals are off by cents. Explain and fix.

Learn this topic