Search
  Home
  Articles
  Backup
  Books
  Certification
  FAQ
  Products
  Replication
  Scripts
  Seminars
  Training
  TSQL

MSDN Fourms
Philippine SSUG

  Resume

MHS Enterprises
FilAm Software
AcrylicAcetate.com
Bargain Humidors
Western Humidor



Naming Conventions 1 2

Always remember that all objects in SQL Server can be up to 30 characters in length. Do not use reserved words, special characters, or start names with a number. Try to avoid the use of abbreviations. Abbreviations make it very difficult for other people to determine what an object does. Naming conventions are neither right nor wrong. They will simply provide a standard way of referencing objects in the database and should eliminate a lot of questions as to the function of a particular object if used properly. If abbreviations are used, they must follow the set of standard abbreviations set specified elsewhere in your set of standards. 

As you can tell from most of the naming conventions, I like lower case names and dislike underscores as well.   This is simply because very few people type in all caps or touch type.   Needing to constantly hit the shift key can get very annoying.  The thing to keep in mind is that these are guidelines.  I only allow deviations from a naming convention in two cases:  it is named differently by the DBMS - system objects or it is a database(s) that come with a packaged product.  You obviously can't modify system object names to match your naming conventions.  Also packaged products are allowed to violate the naming conventions simply so that you do not have to customize the software to accommodate this and in most cases you can't change them without breaking the application.

Please don't get fancy with naming conventions and make them understandable as to the purpose of the object.  Real life example:  One of the clients I was at had some fantastic naming conventions for their databases: BASIC_INFO, USER_INFO, WORK_INFO, etc.  I laughed for quite a while when I saw these.  I especially loved the fact that they went to such great lengths to waste five characters with _INFO.  If it wasn't info, then what the heck was it doing in the database.   The other things that was really nice is I had databases named BASIC, USER, and WORK.  Really nice!  It gave me a name for the database, but told me absolutely nothing about what was in the database or the purpose of the database.  Since the naming conventions were as fabulously descriptive, we were sorely tempted to finish them out with the new databases and name them DATA_INFO, INFO_DATA, DATA_DATA, and INFO_INFO.   Since their names were virtually useless, we didn't think it would hurt to take it to the nth degree.

Database Devices: Database devices shall named for the purpose they serve. If it is a log device, the word log shall appear in the name. A device for data storage shall have the word data in it. If a device is to be designated solely to a single database, the database name shall be part of the database device name. The name shall be in all caps.

Example: CUSTOMERLOG, master, CUSTOMERDATA

Backup Devices: Backup devices shall be named for the type of device they are. All backup device names shall be in all lower case letters.

Example: tapebackup, dbdiskdump

Databases: User databases shall be named in all upper case letters. This will help distinguish them from any system databases which are usually all lower case letters.

Example: CUSTOMER, ACCOUNTING, master

Logins: Logins shall consist of the first letter of the person’s first name and the full last name. All logins shall consist of lower case letters. The exceptions to this are any system level or administrative logins. The sa (system administrator login should be locked up and never used except for those needing system level access).  A separate account should be created for the dbo.  This gives the ability for a single account to own all of the databases and objects, but still not have system level access.

Example: mhotek, swynkoop, dbadmin

Tables: Tables shall be named with words describing their purpose.   Names should be in all lowercase with words run together.  Lookup tables shall be preceded by a zlk_.  The z allows grouping all of these tables at the bottom of the list (most query tools list tables alphabetically) and the lk_ designates that this is a lookup or auxiliary table.

Example: customeraddress, customer, peoplemailinglist, zlk_countrycodes

Naming Conventions 1 2

Michael R. Hotek

All content on this site, except where noted, represents an original work of Michael R. Hotek and is protected by applicable copyright laws. The SQL Server FAQ is the sole work of Neil Pike. No page, portion of a page, or download may be used for commercial purposes in whole or in part without the express, written permission of the applicable author.