Entitix

Metadata and modeling

Naming conventions for tables and columns: a practical standard

  • Updated
  • 5 min read
Contents

Names are the first documentation anyone reads. A column called amt2 tells nothing; invoice_net_amount tells almost everything. A naming standard makes the names of tables and columns predictable, so that people find data by guessing its name, integrations map fields without a meeting, and the catalog reads like a vocabulary rather than a puzzle.

In short

  • A naming standard fixes the case, the word order, the vocabulary and the abbreviations of table and column names.
  • Build column names from what is described, which property and a class word for the kind of value: customer_birth_date.
  • Choose one convention for case and for singular or plural, and apply it everywhere.
  • Keep an approved list of abbreviations, and respect the length limits of your databases.
  • Check names automatically, in the data model and in code review, not by reading.

Principles

PrincipleMeansExample
DescriptiveA name says what the data is without the documentationorder_date, not dt1
ConsistentThe same thing has the same name everywherecustomer_id in every table that refers to a customer
One meaningOne name, one conceptNot status for three different statuses
PredictableNames follow a pattern people can guessEvery date ends in _date
PortableNames work in every system that will hold themNo spaces, accents or reserved words

Building column names

A widely used pattern, in line with ISO/IEC 11179, builds a name from three parts:

  1. an object or entity: customer, invoice;
  2. a property: birth, net, postal;
  3. a class word, also called a representation term, saying what kind of value it holds.
Class wordHoldsExample
idA surrogate or system identifiercustomer_id
codeA value from a code listcountry_code
number or noAn identifier people useinvoice_number
nameA nameproduct_name
dateA calendar datebirth_date
at or tsA date and timecreated_at
amountMoney, with its currency in another columnnet_amount, currency_code
quantity or qtyA count of unitsorder_quantity
rate or pctA ratio or percentageinterest_rate
flag or is_A yes or no valueis_active
text or descFree textdelivery_note_text

Inside its own table the object is often left out (customer.birth_date rather than customer.customer_birth_date), but foreign keys keep it (order.customer_id), so that the same concept has the same name wherever it appears.

Table names

  • Singular or plural: both are defensible; customer reads as the name of an entity, customers as the name of a set. Choose one and never mix them.
  • No type prefixes such as tbl_ or t_: the catalog already knows what is a table.
  • Layer prefixes can help in data warehouses: stg_ for staging, dim_ for dimensions, fact_ for facts. Use schemas instead where the database supports them.
  • Associative tables combine the names of what they link: customer_account.
  • Business words, not system words: payment, not pmt_proc_tbl.

Case, characters and length

  • Case: snake_case is the most common in SQL databases. PostgreSQL turns unquoted names into lower case and Oracle into upper case, so mixed case forces quoting forever.
  • Characters: letters, digits and underscores; start with a letter; no spaces, hyphens or accented characters.
  • Reserved words: avoid names such as order, user, date or group on their own, which need quoting in many databases.
  • Length limits: PostgreSQL allows 63 bytes, MySQL 64 characters, SQL Server 128 characters and Oracle 128 bytes from version 12.2 (30 before). A standard meant for several databases should respect the shortest.

Abbreviations

Full words are clearer, but length limits and long compound names make some abbreviations necessary. Keep them under control:

  • an approved list, one abbreviation per word (amt for amount, qty for quantity, cust for customer);
  • logical models with full words, physical models with the approved abbreviations derived from them;
  • no private abbreviations: if it is not on the list, spell it out.

Keys, constraints and indexes

ObjectPatternExample
Primary keypk_<table>pk_customer
Foreign keyfk_<table>_<referenced table>fk_order_customer
Unique constraintuq_<table>_<columns>uq_customer_email
Check constraintck_<table>_<rule>ck_order_quantity_positive
Indexix_<table>_<columns>ix_order_order_date

Named constraints make error messages and migration scripts readable.

Making the standard stick

  1. Write it down as a standard under the data modeling policy, with examples. See data governance policies, standards and procedures.
  2. Check names automatically in the data modeling tool and in the review of every change. See data model change management.
  3. Apply it to new work first. Renaming existing tables is expensive; plan it with the next major change instead.
  4. Link names to meaning. A good name is no substitute for a definition: link columns to their business terms.

Common mistakes

  • A standard nobody checks. Without automated checks, names drift within months.
  • Mixing conventions for case or plurals across systems that exchange data.
  • Cryptic abbreviations that only their author can read.
  • Encoding volatile facts in names, such as the source system or a year (crm2019_customer).
  • Names without units or currency, so that weight and amount need a meeting to interpret.
  • Renaming everything at once, breaking every consumer for the sake of consistency.

Frequently asked questions

Should table names be singular or plural?

Either works; consistency matters more. Singular names (customer) read as the name of an entity and match the logical model; plural names (customers) read as sets of rows. Choose one in the naming standard and apply it to every table.

What is a class word in a column name?

A class word, or representation term, is the last part of a column name that says what kind of value it holds: date, amount, code, name, id. It makes names predictable and tells readers how to interpret the value before they read any documentation.

Should column names include the table name?

Usually not inside their own table: customer.birth_date is enough. Foreign keys are the exception and should keep the name of what they refer to, such as customer_id in the order table, so that the same concept has the same name everywhere.

How do you enforce naming conventions?

Write the rules as a standard with examples, and check them automatically: in the data modeling tool, in schema migration reviews, or with a linter in the build. Automated checks catch breaches before tables reach production; manual reviews alone rarely keep up.