Database Naming Conventions by Microsoft?

SqlSql ServerTsql

Sql Problem Overview


I found Naming Guidelines from MSDN, but is it any guideline for MSSQL database from Microsoft?

Sql Solutions


Solution 1 - Sql

The naming conventions used in SQL Server's AdventureWorks database demonstrate many best practices in terms of style.

To summarize:

  • Object names are easily understood
  • Table names are not pluralized ("User" table not "Users")
  • Abbreviations are few, but allowed (i.e. Qty, Amt, etc.)
  • PascalCase used exclusively with the exception of certain column names (i.e. rowguid)
  • No underscores
  • Certain keywords are allowed (i.e. Name)
  • Stored procedures are prefaced with "usp"
  • Functions are prefaced with "ufn"

You can find more details here:

One caveat: database naming conventions can be very controversial and most database developers I've met have a personal stake in their style. I've heard heated arguments over whether a table should be named "OrderHeader" or "OrderHeaders."

Solution 2 - Sql

No, there isn't but the practices in the link you provided are good to keep in mind.

With respect to naming stored procedures - do not prefix them with "sp_" You can read more about why in this link:

> "Do not prefix stored procedures with > sp_, because this prefix is reserved > for identifying system-stored > procedures."

Solution 3 - Sql

I don't know what "best practices in terms of style" in the answer by @8kb (at the time of writing) means. Certainly some of the listed items ("Table names are not pluralized", "No underscores", etc) are mere style choices which are obviously subjective. I would have thought the personal preferences of the documentation team lead would be the greatest factor here.

As regards heuristics in SQL in general (as opposed to proprietary SQL such as T-SQL), there is but one book on the subject: Joe Celko's SQL programming style.Many of the choices for SQL Server's AdventureWorks database conflict with Celko's guidelines.

Celko's naming convention is based on on the international standard ISO 11179 e.g. specifies that a delimiting character (such as an underscore) should be used to separate elements in a name. Other style choices are similarly backup up by research e.g. using exclusively lower case letters for column names so aid scanning by the human eye. No doubt there are subjective personal preferences in there too but they are based on many years of experiences out in the field.

On the plus side, things have improved in the SQL Server docs in recent years e.g. SQL keywords capitalized, semi-colons to separate statements, etc. Adventure works is a vast improvement on Northwind and pubs. Now why can't the scripting feature in Management Studio spit out code that is a little easier on the eye?!

Solution 4 - Sql

If you were to build a SQL Server naming conventions guide, I recommend starting with Konstantin's document on GitHub.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionCheungView Question on Stackoverflow
Solution 1 - Sql8kbView Answer on Stackoverflow
Solution 2 - SqlOMG PoniesView Answer on Stackoverflow
Solution 3 - SqlonedaywhenView Answer on Stackoverflow
Solution 4 - SqldatalifenycView Answer on Stackoverflow