Schools of Thought on Naming Tables and Columns

Should a table be called student or students? Should a column be first_name or firstName? People hold strong views on naming, and there is no single official rule. This page lays out the main schools of thought so you can choose one and stick to it.

Keeping data correct illustration

Question 1: singular or plural table names?

Plural school: a table holds many rows, so call it students, books, orders. Many frameworks, including Rails, use plural table names by default.

Singular school: a table describes one kind of thing, so call it student, book, order. Supporters say it reads well in queries like student.name.

Note: some words are awkward either way, and order is a reserved word in SQL, which is one reason people choose orders.

Question 2: how to separate words?

StyleExampleWhere you see it
snake_casefirst_nameVery common in SQL, PostgreSQL and many Python projects
camelCasefirstNameCommon in JavaScript code; less common in SQL
PascalCaseFirstNameOften seen in SQL Server databases and .NET projects

A practical point: PostgreSQL turns unquoted names into lowercase, so FirstName becomes firstname unless you put it in double quotes every time. That is one reason many PostgreSQL users prefer snake_case.

Question 3: what to call the primary key?

**id school:** every table's primary key is simply id. Short and consistent.

**table_id school:** the key is student_id in the students table. Supporters like that the same name appears in every table that refers to it.

Both work. Foreign keys are almost always named after the table they point to, such as student_id in an enrolments table.

Question 4: prefixes?

Some older systems prefix tables with tbl_ or columns with their type, like str_name. Most modern guides advise against this: the database already knows what is a table and what type a column is, and prefixes make names longer.

The schools side by side

ChoiceOption AOption BMost common in beginner tutorials
Table namesPluralSingularPlural
Word separationsnake_casecamelCasesnake_case
Primary keyidtable_idid
PrefixesYesNoNo

What everyone agrees on

  1. Be consistent. Mixing styles is worse than any single style.
  2. Use clear, full words. created_at is better than crtd.
  3. Avoid reserved words like order, user (in some databases), group and select.
  4. Avoid spaces and special characters in names.
  5. Write your rules down in the project README, especially in a team.

A sensible default for a first project

Plural table names, snake_case columns, id as the primary key, foreign keys named thing_id, no prefixes. It matches most beginner tutorials and works smoothly in SQLite, PostgreSQL and MySQL.

CREATE TABLE enrolments (
  id         INTEGER PRIMARY KEY,
  student_id INTEGER NOT NULL,
  course_id  INTEGER NOT NULL,
  created_at TEXT
);

See how naming fits into team work in working on a shared database in a club project.

A free learning page for beginners. Practise on a test database, never on real customer data, and check the official documentation for your database version.

Illustrative outline only: no live session, recording, registration or certificate is offered on this site. Any speakers, panels or schedules mentioned are hypothetical.

Related pages on this site