• Repost - originally posted 06-09-2012

Object naming standards


Do you have a standard naming convention?

Most application databases have standard prefixes for tables (tbl_), views (vw_), user stored prcedures (usp_), user defined functions (udf_) etc.

But do you have a standard for Primary Keys, Foreign Keys, constraints and defaults?

By creating a standard you can make debugging and tracing of violations back to the source a lot quicker. An example would be PK_schemaname_tablename for primary keys. FK_foreigntableschemaname_foreigntablename_foreigntablecolumnname.

Defaults are defined as DEF_schemaname_tablename_columnname.

Check constraints use CHK_ instead of DEF_ and unqiue constraints are UQ_ instead of DEF_.

It is a lot easier to find the issue with UQ_Patient_Picture_FileStreamID rather than a system generated UQ__Picture__2957490CF9A66DF5, although there can be an issue with the name becoming too long and unwieldly.

Just have a standard that works for you.


2 views

Recent Posts

See All

Cardinality estimator

Recently I was asked by a software vendor to review a particular query that ran in under a second on a SQL Server 2014 installation at a compatibility level of 110 (SQL Server 2012), but when run unde

Index fragmentation

A law firm client, occasionally has issues with their legal software, that is provided by the global leader in this field. The response from the software provider is always the same - you have index f

Deleting large amounts of data

I had a client call me about wanting to delete a large amount of data from their database. They knew what tables they wanted to delete from. They also knew that deleting large amounts of data causes t