Habits That Make Table and Column Names Easy to Live With
Names are the part of a database you read every single day. Good ones make queries easy to write and understand; poor ones cause confusion for years, because renaming later is hard. These habits come with a reason and a counter-example each.
1. Pick one style and keep it
Good: order_items, created_at, customer_id (lowercase with underscores, often called snake_case).
Avoid: mixing OrderItems, created_at and CustomerID in one database.
Why: some databases treat upper and lower case differently, and mixed styles force you to remember which is which. PostgreSQL, for instance, folds unquoted names to lower case, so CustomerID becomes customerid unless you quote it every time.
2. Choose plural or singular table names, once
Good: always customers, orders, products, or always customer, order, product.
Avoid: customers next to order.
Why: both conventions are common; consistency is what matters. Note that order is a reserved word in SQL, which is one reason many people prefer plural table names.
3. Name the primary key predictably
Good: id in every table, or customer_id in customers, used consistently.
Avoid: id in one table, ID in another, cust_no in a third.
4. Name foreign keys after what they point to
Good: orders.customer_id points to customers.id.
Avoid: orders.cust or orders.c1.
Why: anyone reading a JOIN can see the relationship immediately:
SELECT o.id, c.name
FROM orders o
JOIN customers c ON c.id = o.customer_id;
5. Make booleans read like questions
Good: is_active, has_paid, email_verified.
Avoid: status for a true-or-false value, or flag2.
6. Put units in names where it matters
Good: weight_grams, duration_seconds, price_cents.
Avoid: weight, leaving readers to guess kilograms or pounds.
7. Avoid reserved words and spaces
Avoid: columns named order, user, select, group, or names with spaces like first name.
Why: they need quoting in every query, and some tools handle them badly.
8. Be specific, not clever
Good: shipping_address, billing_address.
Avoid: addr, addr2, data, info, misc.
A quick naming checklist
| Question | Yes means good |
|---|---|
| Is the style the same as other tables? | Consistent |
| Could a newcomer guess what the column holds? | Clear |
| Does a foreign key name say what it points to? | Readable joins |
| Is it free of reserved words and spaces? | No quoting needed |
| Are units included where values have them? | No guessing |
When you inherit messy names
You do not have to rename everything. Use aliases in queries (SELECT cust AS customer_id) and apply good names to new tables. Renames are best done carefully with schema migrations, one at a time.
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.