Database Naming Conventions by Microsoft?
Solution 1:
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:
- AdventureWorks Data Dictionary
- Stored Procedures in AdventureWorks
- Functions in AdventureWorks
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:
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:
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:
If you were to build a SQL Server naming conventions guide, I recommend starting with Konstantin's document on GitHub.