Felipe Pessoto
Felipe Pessoto

Reputation: 6969

Naming database table fields

Exists any naming guideline for naming columns at Sql Server? I searched at MSDN, but dont found anything, just for .Net

Upvotes: 1

Views: 302

Answers (4)

Mike J
Mike J

Reputation: 3159

I find the following short list helpful:

  1. Name tables as pluralnouns (or singular, but as a previous response stated, be consistent) for example "Customers", "Orders", "LineItems"
  2. Stored procedures should be named without any prefixes such as "sp_" since SQL Server uses the "sp_" prefix to denote special meaning for system procedures.
  3. Name columns as though as you would name attributes on a class (without using underscores)
  4. Try not to use space characters in naming columns or database entities since you would have to escape all names with "[...]"
  5. Many-to-many tables: for example "CustomerOrders"

Upvotes: 1

Adam Batkin
Adam Batkin

Reputation: 53024

There are lots of different conventions out there (and I'm sure other answers may make some specific suggestions) but I think that the most important thing is that you be consistent. If you are going to use a prefix for something, use it everywhere. If you are going to have a foreign key to another table, use the same column name everywhere. If you are going to separate words with underscores, do that everywhere.

In other words, if someone looks at a few tables, they should be able to extrapolate out and guess the names of other tables and columns. It will require less mental processing to remember what things are called.

Upvotes: 3

Adrian Grigore
Adrian Grigore

Reputation: 33318

As always, google is your friend...

Upvotes: 1

Mitchel Sellers
Mitchel Sellers

Reputation: 63136

There are many resources out there, but nothing that I have been able to truly pin down as a SQL Server specific set or anything published by Microsoft.

However, I really like this list.

Also, very important to NOT start out stored procedures with sp_

To be 100% honest though, the first part of my posted link is the most important. It must make sense for your organization, application, and implementation.

Upvotes: 1

Related Questions