Lecture

Column Naming & Conventions

Consistent, clear naming makes databases easier to understand, maintain, and scale — especially when working in a team.

In this lesson, you’ll learn how to name tables and columns 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.

Snake case example
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’s sometimes used in programming languages, but less common in SQL.

Pascal case example
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

Avoid using reserved words like SELECT, WHERE, or ORDER as column or table names:

Avoid using order as a table name
-- 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.

Using client_id instead of id
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.

Client orders schema example
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.

Quiz
0 / 1

Which column name follows snake_case?

StudentID

FullName

student_id

full name

Lecture

AI Tutor

Design

Upload

Notes

Favorites

Help

Code Editor

Run
Generate

Tables

Execution Result