Intro

The main reason to adopt a naming convention is so you and others can easily understand the structure. Naming conventions should produce concise, legible, unambiguous, and consistent names. Naming conventions should clarify instead of confuse; the strictest adherence to naming conventions will result in ridiculous names.

Who should adopt a naming convention? The following should:

It is common to have names composed of different parts. Here are some common syntaxes:

[prefixes]{tag}[BaseName][Qualifiers]
[tagprefixes][tag][PREFIXES_]{BaseName}[Qualifiers][_SUFFIXES]

All Database Objects

Limit the length. Shorter is better. Here are actual DBMS maximum lengths for column names:

Use only ASCII letters, numbers, and underscore (_). The first character should be a letter since some DBMSs don't accept anything else as the first letter. Here are some details of the actual DBMS character restrictions:

Avoid abbreviations. If an abbreviation must be used, then avoid ambiguous or inconsistent abbreviations, and try to use the same abbreviation throughout the databases. EG:

Here are some pretty common database abbreviations from the University of Arizona:

Name Abbreviation Description
Amount Amt A monetary value.
Category Catgy A specifically defined division or subset in a system of classification in which all items share the same concept of taxonomy.
Code Cd A combination of one or more numbers, letters, or special characters which is submitted for a specific meaning (includes Status and Abbreviation).
Date Dt The notion of a specific period of time.
Description Descn A word or phrase which interprets an abbreviation, code or other shortened term so as to make it more understandable to users (i.e., Arizona is the description of the abbreviation AZ).
Identifier Idfyr A combination of one or more integers, letters, special characters which designate a specific object/entity, but has no readily definable meaning (includes Designator, Key, Number).
Indicator Indcr An identifier which has a domain of only 2 states, such as: Y/N, ON/OFF,TRUE/FALSE, 0/1, etc.
Name Nm The designation of an object/entity expressed in a word or phrase.
Number Nbr A value which is not for the purpose of measuring a quantity or serving as a counter, but which is usually a numeric value (it may contain non-numeric characters, such as a Product Number, PO Number, etc.). It is distinguishable in that arithmetic operations are not usually carried out on it.
Quantity Qty A non-monetary value. (Includes: Average, Balance, Deviation, Factor, Index, Level, Mean, Median)
Rate Rt A quantity, amount or degree of something in relation to units of something else. (Includes: Factor, Frequency, Percent, Scale)
Text Txt An unformatted character string, generally in the form of words. (Includes: Abbreviation, Comments)
Time Tm A notion of a specified chronological point within a period.

Make names readable. A rule of thumb is that you should be able to read the name to someone over the phone without having to spell out portions. Note that too many abbreviations violates this rule.

Use mixed case, especially to distinguish between "words" within a part of a name. EG: ProductName. Some folks like to use underscore (_) to separate parts of a name. EG: HR_Status and HR_Ballots. I personally find that practice annoying. Plus there are more creative uses for the underscore (see Tables below).

It has been suggested by the Leszynski and Reddick to use the following prefixes to indicate the status of certain database objects. Note that z is used to make the items appear at the top of lists. I suggest adding the developer's initials or name after each of these prefixes so we know who to contact about the status of these items.

Use nouns for most objects. EG: vueEmployee. Use verbs (EG: Multiply()) or verb and noun combinations (EG: AddDog()) for objects that do things such as functions or stored procedures. If you use verb and noun combinations, be consistent with the order, i.e. use NounVerb() or VerbNoun(). The latter is closer to English and is good for sorting a list according to the action taken, but the former is better for sorting a list of functions according to the object they work on.

This shouldn't need to be said, but avoid naming anything with a reserved word.

Databases

Tables

Columns

Indexes

Views and Queries

Stored Procedures

User Defined Functions

Triggers

Constraints, Defaults, and Rules

SQL Statement Variables

In SQL Server, variables follow this syntax:

It is worth while to prefix variable names with data type. Here is a table of common prefixes:

Access
Data Type Prefix
binary bin
byte byt
b
counter lng
currency cur
date/time dtm
dt
double dbl
flt
hyperlink lnk
integer int
i
w
long lng
dw
l
i
memo mem
OLE ole
single sng
sgl
flt
text str
txt
sz
s
yes/no ysn
bln
f
SQL Server
Data Type Prefix
char(n) & nchar(n) chr, nchr
str
s
varchar(n) & nvarchar(n) vchr, nvchr
str
s
text & ntext txt, ntxt
datetime dtm
dt
smalldatetime sdtm
dtm
dt
bit bit
f
binary(n) bin
b
varbinary(n) vbin
bin
b
image img
decimal[(p[,s])] dec
num
flt
numeric[(p[,s])] num
flt
float[(n)] flt
num
real rel
flt
real
bigint bint
int
i
int int
i
smallint sint
i
tinyint tint
int
i
money mny
smallmoney smny
mny
cursor crsr
sql_variant vnt
v
table tbl
timestamp tmst
tmstp
uniqueidentifier guid
user defined udt
t

It may also be worth while to use these various name modifiers:

Backup Files

Users and Logins

Bibliography

Listed in no particular order are sources referenced while making this page:

Charles Simonyl is credited with the Hungarian naming convention of prefixing base names with lower case tags such as strObject.

Page Modified: (Hand noted: 2007-10-06 05:57:36Z) (Auto noted: 2007-11-17 06:47:55Z)