Quick revision
The short answer
I would write a short standard that gives the type and the reason for each common concept: money, instants, identifiers, text lengths, booleans, enumerations and JSON. New schema changes are checked automatically by migration linting in CI, such as squawk for PostgreSQL or custom Flyway or Liquibase checks, while existing violations are fixed in order of risk, starting with money stored as float and local timestamps in cross-region data. Shared Java types and mappings, such as a Money type and Instant, make the right choice the easy one, and justified exceptions go into a register with an owner instead of blocking work.
What to remember
In this answer, we built a short type standard that explains its reasons, enforced it on new migrations through linting in CI with squawk or Flyway and Liquibase checks, fixed existing violations in order of risk with money in float and local timestamps first, made the right types the default through shared Money and Instant mappings, and kept exceptions in a register with owners so the standard never stalls delivery.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
I would write a short standard that gives the type and the reason for each common concept: money, instants, identifiers, text lengths, booleans, enumerations and JSON. New schema changes are checked automatically by migration linting in CI, such as squawk for PostgreSQL or custom Flyway or Liquibase checks, while existing violations are fixed in order of risk, starting with money stored as float and local timestamps in cross-region data. Shared Java types and mappings, such as a Money type and Instant, make the right choice the easy one, and justified exceptions go into a register with an owner instead of blocking work.
Background to this question
Inconsistent column types across 50 services sound like an aesthetic problem until they cause real damage: an amount stored as float in one service and numeric in another produces reconciliation differences, a timestamp without time zone in a service that moved regions shifts events by hours, and an int id overflows. The leadership challenge is to fix the risky cases and stop new ones without turning the platform team into a review gate that every team has to queue for. In this answer, we will look at what the standard should contain, how to enforce it on new code automatically, how to prioritise existing violations, how shared libraries make compliance easy, and how to handle exceptions.
1Writing a Short Standard With Reasons
The standard must fit on two pages, otherwise nobody reads it. It covers the concepts that every service has, with one recommended type, the reason, and the anti-pattern to avoid. The reason matters more than the rule: an engineer who understands that float cannot represent 0.10 exactly will make good decisions in cases the standard did not foresee.
| Concept | Use | Avoid | Reason |
|---|---|---|---|
| Money | numeric(19,4) or bigint minor units | float, double, varchar | exact decimal arithmetic |
| Instants | timestamptz | timestamp, varchar | no offset means ambiguous times |
| Identifiers | bigint identity or uuid | int | int overflows at 2.1 billion |
| Text | text, with CHECK on length if needed | varchar(255) by habit | same speed; limits should mean something |
| Booleans | boolean NOT NULL | char(1) Y/N, int 0/1 | one representation, no third value |
| Enumerations | text + CHECK or lookup table | native enum, magic ints | easy to evolve |
| JSON | jsonb, for truly flexible data | json, or jsonb for core fields | core fields need types and constraints |
2Enforcing the Standard on New Schema With Linting
Rules that rely on review are applied unevenly. So the first enforcement is automatic: every migration file is checked in CI before it can merge. For PostgreSQL, squawk is an open-source linter that reads migration SQL and flags risky operations, such as adding a NOT NULL column without a default or creating an index without CONCURRENTLY. We extend this with our own rules for types, for example failing on real or double precision columns named like amount or price, and on timestamp without time zone.
For teams using Flyway or Liquibase, the same checks can run as a build step or a custom rule set, and for teams that generate schema from JPA entities, an ArchUnit test can check entity field types, such as rejecting double fields for money. The linter's messages link to the standard, so a failing build teaches instead of merely blocking.
3Fixing Existing Violations by Risk
The existing 50 services will have hundreds of violations, and fixing them all is neither possible nor worth it. I would inventory them automatically, by querying information_schema in each database for column types, and rank them by risk. Money in float is first, because it produces wrong numbers that reach customers and finance. Local timestamps in data that crosses regions come next, because they produce wrong orderings and wrong reports. int primary keys near overflow are urgent by date. varchar for numbers or inconsistent booleans are low risk and can wait for the next time someone touches that table.
- Inventory columns in all databasesautomated, from information_schema
- Money stored as float or text?YesFix this quarter, with financeNoNext check
- Local timestamp in cross-region data?YesFix this half-yearNoNext check
- int key above 50 percent of range?YesPlan migration by dateNoNext check
- Low-risk inconsistencyFix when the table changes anyway
5 steps in order. Play them, or step through them one at a time.
4Making the Right Choice the Easy One
Teams copy what is closest to hand. If the shared platform library provides a Money value type with a JPA mapping to numeric and a currency, and the Spring Boot starter configures Jackson and Hibernate to use UTC with Instant, then the standard is what happens by default. A service template with an example entity that uses those types does more for adoption than any document.
Embeddable records are supported by Hibernate 6.2 and later, which is worth confirming for the versions each team uses.
5Tracking Exceptions Instead of Blocking Work
Some violations are deliberate. A service may store a legacy partner's amounts as text because the partner sends values beyond any fixed precision, or keep int ids because the table will never pass a few thousand rows. Rather than forcing a fight in every such case, the linter allows an exception annotation that points to an entry in a register: what the exception is, why, who owns it, and when it will be reviewed. That keeps the standard credible, because exceptions are visible and owned, and it keeps teams moving, because they never have to wait for permission to ship something reasonable.
I would report the numbers quarterly: new violations caught in CI, high-risk violations fixed, exceptions open. Seeing the risky count go down is what keeps leadership support for the work.
6Follow-up questions
How do you get 50 teams to accept the standard?
By writing it with them rather than for them. I would draft it with a few senior engineers from different teams, publish it as a proposal with a comment period, and make sure each rule has a reason that has caused a real incident. Starting the linter in warning mode for a month also lets teams see the impact before it blocks anything.
Should uuid or bigint be the standard for identifiers?
Both are acceptable, and the standard should say when to use each. bigint identity is compact and fast for internal keys. uuid is useful when ids are generated outside the database or must not be guessable, and UUID version 7, which is time-ordered and is generated natively by uuidv7() in PostgreSQL 18, avoids the index locality problems of random version 4 values. What matters is never using int for anything that can grow.
7Conclusion
In this answer, we built a short type standard that explains its reasons, enforced it on new migrations through linting in CI with squawk or Flyway and Liquibase checks, fixed existing violations in order of risk with money in float and local timestamps first, made the right types the default through shared Money and Instant mappings, and kept exceptions in a register with owners so the standard never stalls delivery.
Open with
I'd start with a short standard, two pages at most, covering the concepts every service has: money as numeric or bigint minor units, instants as timestamptz, identifiers as bigint or uuid, text, booleans, enumerations as text with a CHECK or a lookup table, and when jsonb is appropriate.
Then, if they want more
Each rule has its reason, because engineers who understand why float can't represent 0.10 will make better calls than ones following a list. For new schema I'd enforce it automatically with migration linting in CI, squawk for PostgreSQL plus custom checks in the Flyway or Liquibase pipeline, with error messages that link to the standard.
For existing services I'd inventory column types from information_schema and fix by risk: money in float first, then local timestamps in cross-region data, then int keys approaching overflow; low-risk inconsistencies get fixed when the table changes anyway.
To make it easy, the platform provides shared Java types, a Money embeddable and Instant with UTC configuration in our Spring Boot starter, so the default is correct. Finally, deliberate exceptions go into a register with an owner and a review date, instead of blocking teams, and I'd report progress quarterly.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Hibernate 6, PostgreSQL 18
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- PostgreSQL documentation, The SQL Language
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Across 50 services, column types for the same concepts differ: amounts as float, numeric...": https://scrivio-interview-library.netlify.app/databases/sql-fundamentals/37b339361e/