Naming Convention guideline or rules for database objects in SQL Server 2005:

Tuesday, March 17, 2009 |

Naming convention should be used for any database objects in order to maintain consistency and accuracy. Naming convention is not defined by Microsoft; you can define your own naming convention and can follow it throughout your database. Herewith, I am giving naming convention guideline which I am following. There could be a debate in some naming convention rules but as I told you this is what I am following.

Database Naming Convention Guide line:

Use only alphabetic value for database name. Don’t use hyphen or underscore in database name. Don’t use space in database name also or else you have to surround your database name every time with square brackets.

Table Naming Convention Guide line:

Use plural name for table name. Some people would like to debate on this topic for using singular name for table and they might have their own reason as well.

Abbreviation of module should be used as prefix like: purInventoryMaster. This will help us managing tables of modules together.

Each word of table name should be capital to make it more readable like InventoryMaster is more readable than inventorymaster or INVENTORYMASTER.

Space or underscore shouldn’t be used in table name and should starts with alphabetic character.

You should also create and use appropriate Schema with table name and reserve word should not be used.

Column Naming Convention Guide line:

Column name represent entity of your table. Column name should represent the entity rather than table name. It should use first letter of each word capital like CustomerName. Space should be avoided in column name so that you don’t need to bother about square brackets uses.

Reserve word should not be used.

Stored Procedure and Function Naming Convention Guide line:

Always give appropriate name to Stored Procedure of Function show that use can understand its usage by just reading the name, they don’t need to view the code inside. You can use verb, noun etc. to make it clear like UpdateCustomerInfo or maybe you can suffix SP’s input parameter like GetOrderIDbyCustomerName etc.

Don’t use sp_ as a prefix for stored procedure as it has special meaning to it. I wrote one article for that, if you are interested then do visit it at http://ritesh-a-shah.blogspot.com/2009/03/create-your-own-system-stored-procedure.html

Indexes Naming Convention Guide line:

You can have clustered or non-clustered index and maybe unique or non-unique index, generally you used to assign index on one or more columns. I used to given index name like NcSalesSalesID out of which “NC” belongs to “NonClustered”, “Sales” is a table name and “SalesID” is a column name.

Above are the basic guidelines for naming convention. List can grow more but these are the basics I am using.

Rererence: Ritesh Shah

0 comments: