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.
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?
| Style | Example | Where you see it |
|---|---|---|
| snake_case | first_name | Very common in SQL, PostgreSQL and many Python projects |
| camelCase | firstName | Common in JavaScript code; less common in SQL |
| PascalCase | FirstName | Often 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
| Choice | Option A | Option B | Most common in beginner tutorials |
|---|---|---|---|
| Table names | Plural | Singular | Plural |
| Word separation | snake_case | camelCase | snake_case |
| Primary key | id | table_id | id |
| Prefixes | Yes | No | No |
What everyone agrees on
- Be consistent. Mixing styles is worse than any single style.
- Use clear, full words.
created_atis better thancrtd. - Avoid reserved words like
order,user(in some databases),groupandselect. - Avoid spaces and special characters in names.
- 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.