The following are recommended naming conventions for SQL Server.
Object | Naming Convention | Example |
database device | (business name) | sales |
data device | (business name) + _data | sales_data |
log device | (business name) + _log | sales_log |
dump device | (business name) + _dump | sales_dump |
table constraint | (business name) | customer |
foreign key constraint | (table name) + _fk | customer_fk |
primary key constraint | (table name) + _pk | customer_pk |
unique key constraint | (table name) + _uniq | customer_uniq |
or | ||
foreign key constraint | fk_ + (table name) | fk_customer |
primary key constraint | pk_ + (table name) | pk_customer |
unique key constraint index | uniq_ + (table name) | uniq_customer |
clustered | (column_name) + _cdx | customer_id_cdx |
nonclustered trigger | (column name) + _idx | customer_id_idx |
delete | (table name) + _dtr | customer_dtr |
insert | (table name) + _itr | customer_itr |
update | (table name) + _utr | customer_utr |
insert and update | (table name) + _iutr | customer_iutr |
or | ||
delete | dtr_ + (table name) | dtr_customer |
insert | itr_ + (table name) | itr_customer |
update | utr_ + (table name) | utr_customer |
insert and update | iutr_ + (table name) | iutr_customer |
stored procedure (style A) | usp_ + (business name) (usp stands for user-defined stored procedure) | usp_customer_inquiry |
stored procedure (style B) | This style combines the action being performed in the stored procedure with a business name. For example, a stored procedure that deletes the customer profile has the name del_customer. If the stored procedure performs multiple business functions, use oth_ + (business name). | |
DELETE | del_ + (business name) | del_customer |
INSERT | ins_ + (business name) | ins_customer |
SELECT | sel_ + (business name) | sel_customer |
UPDATE | upd_ + (business name) | upd_customer |
Other types of actions | oth_ + (business name) | oth_customer |
view | (business name) + _view | customer_view |
TIP: SQL Server is case sensitive. I generally make everything lowercase to avoid confusion.
To order books from QUE, call us at 800-716-0044
or 317-361-5400.
For comments or technical support for our books and software, select Talk to Us.
© 1997, QUE Corporation, an imprint of Macmillan Publishing USA, a Simon and Schuster
Company.