SQL Server Naming Conventions

SQL Server

A great post on SQL Server naming conventions, including why you want to create one, who should use them, why they are important, and how they should be used. This post by Aaron Bertrand provides some great material that should get your ideas flowing on what your naming convention should look like.

Since I know some of you like to minimize reading and scrolling, I’ll sum up my counter-points to the post:

  • In SQL Server, identifiers do not need to be all lower case to avoid quoted identifiers, and hence snake case is unnecessary, too. Snake case also introduces issues for some of Sehrope’s other conventions.
  • A table is a set of things, and therefore should be named plural rather than singular – even if, sometimes, a table might only have one row.
  • Single-column keys should not be named id – if it’s a CustomerID, it should be called CustomerID always, not most of the time.
  • It’s not practical or necessary to always include both table names, all column names, and the type of constraint in a foreign key constraint name.
  • It’s not practical or necessary to always include the table name and the type of constraint in a check constraint name.
  • Some of Sehrope’s points conflict with each other, such as the use of namespace prefixes.

Read on for more details. I would have commented on the page directly, but it’s an older post, I’m not sure if comments are moderated properly, and I am certain I would exceed the max length of a comment anyway.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s