SQL Server Naming Conventions(ejstembler.com)

submitted by ejstemblerejstembler(85) 4 years, 7 months ago

A set of naming convention standards when starting a new SQL Server database.

7 comments |category: |Views: 627

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

posted by jstangroomejstangroome(665) 4 years, 7 months ago 0

Minus 1 kick.

"Blog" has no comments feature nor an RSS or Atom feed.

I agree with most content of the article except for:

1. Keyword Casing - SMSS may code color keywords but we don't always get to work with queries in an editor with coloring. Upper case doesn't hurt.

2. Excess white space - If you are familiar with column-selection (Shift+Alt+drag in SMSS and VS2005) you'll find aligning field names and types and assignments very useful.

3. FieldName and Parameter casing - most forms are good if they are consistent, I go with FxCop casing rules because most field names in SQL end up as objects and properties in .NET.

Reply

posted by ejstemblerejstembler(85) 4 years, 7 months ago 0

Yeah, I'll add comments and feeds eventually. I'm writing the blog engine from scratch in my sparse free time. Just finished the tag cloud functionality...

Reply

posted by offwhiteoffwhite(975) 4 years, 7 months ago 0

I agree. It is not a blog without a feed or comments.

I am not sure how I feel about the uppercase keywords. I do not like holding down shift all that often but it does make the scripts look more readable. It does make sense when a script is viewed outside of SMSS where it is not color-coded. But I use Notepad2 which does color-code known files like SQL scripts. But in a book that is in black and white I would prefer the uppercase keywords.

As for prefixing, I like to prefix common objects. The ASP.NET Membership provider creates a set of tables and stored procedures which are all prefixed with aspnet. I like that because I know they are a part of that system. For the applications I build I do the same so that a single database can stay organized with many groups of objects without a potential conflict. A set of schemas could also be used, but I think that over-complicates matters because that pulls in additional requirements for permissions. I try to only use schemas when I intend to limit access to a set of objects.

Reply

posted by ejstemblerejstembler(85) 4 years, 7 months ago 0

Yes, it's too bad Microsoft used that naming convention for the ASP.net membership objects. With SQL Server 2005 they could have just used an schema instead. For instance, instead of dbo.aspnet_Users, they should have used ASPNet.Users.

Check out Microsoft's AdventureWorks sample database for an example of how to correctly name tables using schemas. You'll notice that they use several schemas: HumarResources, Person, Production, Purchasing, and Sales.

Reply

posted by pohodovkapohodovka(0) 4 years, 7 months ago 0

Maybe I'm missing something here but I find the aspnet_ prefixes very useful.
I don't know what projects you guys work on but with web hosting you usually get one database and with prefixes you can easilly recognize your tables from the aspnet ones.

Reply

posted by BlackWaspBlackWasp(4024) 4 years, 7 months ago 0

Not a bad article but like other readers, I can't agree with the items on casing or whitespace. There is an assumption here that colour coding will always be available (and that the user is not colour-blind enough to lose the distinctions). There is no harm in using upper case or additional whitespace (indeed, there is often a positive benefit) so there is no reason not to use it.

Reply

posted by senfosenfo(881) 4 years, 7 months ago 0

I thought you could supply your own custom prefix when the database was built. Maybe I'm thinking of something else.

Reply

information Login or create an account to comment on this story