Metadata and modeling
Naming conventions for tables and columns: a practical standard
Contents
Names are the first documentation anyone reads. A column called amt2 tells nothing; invoice_ 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
| Principle | Means | Example |
|---|---|---|
| Descriptive | A name says what the data is without the documentation | order_, not dt1 |
| Consistent | The same thing has the same name everywhere | customer_ in every table that refers to a customer |
| One meaning | One name, one concept | Not status for three different statuses |
| Predictable | Names follow a pattern people can guess | Every date ends in _ |
| Portable | Names work in every system that will hold them | No spaces, accents or reserved words |
Building column names
A widely used pattern, in line with ISO/IEC 11179, builds a name from three parts:
- an object or entity:
customer,invoice; - a property:
birth,net,postal; - a class word, also called a representation term, saying what kind of value it holds.
| Class word | Holds | Example |
|---|---|---|
id | A surrogate or system identifier | customer_ |
code | A value from a code list | country_ |
number or no | An identifier people use | invoice_ |
name | A name | product_ |
date | A calendar date | birth_ |
at or ts | A date and time | created_ |
amount | Money, with its currency in another column | net_, currency_ |
quantity or qty | A count of units | order_ |
rate or pct | A ratio or percentage | interest_ |
flag or is_ | A yes or no value | is_ |
text or desc | Free text | delivery_ |
Inside its own table the object is often left out (customer. rather than customer.), but foreign keys keep it (order.), so that the same concept has the same name wherever it appears.
Table names
- Singular or plural: both are defensible;
customerreads as the name of an entity,customersas the name of a set. Choose one and never mix them. - No type prefixes such as
tbl_ort_: 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, notpmt_.proc_ tbl
Case, characters and length
- Case:
snake_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.case - Characters: letters, digits and underscores; start with a letter; no spaces, hyphens or accented characters.
- Reserved words: avoid names such as
order,user,dateorgroupon 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 (
amtfor amount,qtyfor quantity,custfor 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
| Object | Pattern | Example |
|---|---|---|
| Primary key | pk_ | pk_ |
| Foreign key | fk_ | fk_ |
| Unique constraint | uq_ | uq_ |
| Check constraint | ck_ | ck_ |
| Index | ix_ | ix_ |
Named constraints make error messages and migration scripts readable.
Making the standard stick
- Write it down as a standard under the data modeling policy, with examples. See data governance policies, standards and procedures.
- Check names automatically in the data modeling tool and in the review of every change. See data model change management.
- Apply it to new work first. Renaming existing tables is expensive; plan it with the next major change instead.
- 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
weightandamountneed 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. is enough. Foreign keys are the exception and should keep the name of what they refer to, such as customer_ 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.