Column Naming & Conventions
Consistent and clear naming makes SQL databases easier to understand, maintain, and scale—especially when working with a team.
In this lesson, you will learn how to name columns and tables effectively.
General Best Practices
Follow these best practices to ensure clarity and consistency when naming columns and tables in SQL.
Use a single naming convention throughout
Choose one convention and apply it to all columns and tables in your database.
Snake case uses lowercase letters with underscores to separate words.
It is widely used because it is easy to read, type, and keep consistent.
CREATE TABLE clients_info (
id INT PRIMARY KEY,
name TEXT,
contact_number TEXT,
created_at DATE
);
PascalCase capitalizes the first letter of each word.
It can be more common in certain programming environments, but is less common in SQL.
CREATE TABLE ClientsInfo (
Id INT PRIMARY KEY,
Name TEXT,
ContactNumber TEXT,
CreatedAt DATE
);
Tip:
snake_case
is the most popular convention in SQL because it improves readability and avoids case sensitivity issues in many database systems.
Avoid reserved SQL keywords
Don't use words like SELECT
, WHERE
, or ORDER
as column or table names:
-- Avoid this
CREATE TABLE order (...);
Use descriptive names
Use names that describe the data they contain.
For example, client_id
is better than id
because it is more descriptive.
CREATE TABLE clients (
client_id INT PRIMARY KEY,
name TEXT,
contact_number TEXT,
created_at DATE
);
Well-Named Table Example
The example below shows a well-named table.
CREATE TABLE client_orders (
order_id INT PRIMARY KEY,
client_id INT,
order_total REAL,
placed_at DATE
);
Good naming makes it easier to understand queries at a glance, avoid errors and confusion, and keep the database consistent over time.
Want to learn more?
Join CodeFriends Plus membership or enroll in a course to start your journey.