SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Site Related Forums
 Article Discussion
 Article: Database object naming conventions for SQL Server
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

AskSQLTeam
Ask SQLTeam Question

USA
0 Posts

Posted - 05/20/2001 :  22:48:51  Show Profile  Visit AskSQLTeam's Homepage  Reply with Quote
Narayana Vyas Kondreddi submitted "Database object naming conventions for SQL Server: This page proposes a database naming convention for SQL Server, which insists on natural and readable names."

Article Link.

rihardh
Constraint Violating Yak Guru

Slovenia
307 Posts

Posted - 07/04/2001 :  03:05:18  Show Profile  Reply with Quote
It's always interresting to see other naming conventions for database design. The only thing I would add to my names of objects is a suffix (tables _T, views _V,...) It's much easier to know what db object is referenced in a part of a two page code.

Go to Top of Page

nr
SQLTeam MVY

United Kingdom
12543 Posts

Posted - 07/04/2001 :  03:56:15  Show Profile  Visit nr's Homepage  Reply with Quote
From a database point of view there is no need to worry about naming as sql server keeps all object types seperate. Just make sure the name is descriptive (or not desriptive if you are worried about security).
It may be useful to give a prefix for views as it it not obvious from code that you are working on a view or table and they act differently (I don't use them so don't have the problem).

Stored procs - depends on the client code whether these need a prefix. You should have a standard call method so can easily find all SP calls. If the calls aren't controlled though you may want a prefix to find them.

I would stay away from any standard that suggests that tables, columns, datatypes... all have prefixes.

Saying that though - if you have several systems using the same database you may want to prefix all objects dedicated to a single system with an identifier to keep them seperate. Another (poor?) option is to keep all those objects in separate databases.

==========================================
Cursors are useful if you don't know sql.
Go to Top of Page

AjarnMark
SQL Slashing Gunting Master

USA
3246 Posts

Posted - 07/16/2001 :  17:00:16  Show Profile  Visit AjarnMark's Homepage  Reply with Quote
Personally, I don't care for suffixes, but I do prefix my views with V_, although, like nr, I RARELY use them.

I prefer to keep my basic Insert/Update/Delete sprocs named as ObjectAction (e.g. CustomerInsert) so that the sprocs for Customer are grouped together (actually, so that the SQL Scripts I use to Create/modify the sprocs are grouped together). Although other sprocs that do more activity tend to be named with the verb first.

In regard to tables, I prefer NO plurals. But either way, I'd bet everyone would agree the most important thing is to pick a naming convention and stick with it CONSISTENTLY. After all, that's what it's there for.

Go to Top of Page

klprasad
Starting Member

2 Posts

Posted - 09/18/2001 :  17:19:04  Show Profile  Reply with Quote
I dont know why you have to even discuss things like this.I believe in keeping things simple and readable.If a layman or a beginner sees our tables,it should be clear to him what he is looking into.So I always encourage putting a prefix tbl,trg etc.
Why do you make things complex(i know its not complex to some of us,but still why do you change something which is very simple and easily understandable).There will be a difference in time(even though split seconds,the moment you see) your mind understands the way it is when not using prefix and when we use prefixes.I bet it does.

Go to Top of Page

RocketScientist
Official SQLTeam Chef

USA
85 Posts

Posted - 07/21/2003 :  15:23:05  Show Profile  Visit RocketScientist's Homepage  Reply with Quote
I've got to disagree with some of the article.

Table names should always be singular. Because (1) I said so and (2) because you end up with things like the article's example: TerritoriesManagers. Yick. Asthetically not pleasing. You're also relying on everyone to remember the singular/plural forms for everything (Quick, what's the plural for stadium? Media?) (Answer: Stadia, and Media is already plural, the singluar is Medium).

There really are only 3 rules to remember on object naming: Consistency, consistency, and consistency. If you're going to abbreviate something, always abbreviate it the same way (I usually just don't ever abbreviate anything). Don't abbreviate AccountPayable as ACCPAY once and AcctPayb the second time. Always abbreviate the same. Always name your key fields after the table (AccountPayableID), and not some off-the-wall abbreviation. If you maintain consistency you'll tend to guess what object names are more often than not.

I tend to agree with the v_ notation for views, however, most of the time I use a view it's for backward compatibility (we need to change the table structure, but don't have time to change all the old applications) so I end up naming the view the same as the old table, and building the new table with a new (correct) name.



Go to Top of Page

OOPLord
Starting Member

USA
1 Posts

Posted - 10/31/2005 :  15:36:14  Show Profile  Reply with Quote
I absolutely disagree with the premise that tables should be singular and here's why;

1. A table is not a single entity, it holds a group of entities.
2. A row in a table is a representation of a single entity
a. A row is a customer
b. The table that holds them holds customers, not customer.
3. The name of a thing should describe what it is.

If we expand the name out to what is actually being said it becomes clear.

A table that holds customer -or- A table that holds customers

Which is (a) gramatically correct, and (b) makes sense?

Go to Top of Page

ericis_com
Starting Member

USA
2 Posts

Posted - 05/10/2006 :  15:19:20  Show Profile  Visit ericis_com's Homepage  Reply with Quote
I have personally struggled with this for a long time, but recent enlightenment has given me a new perspective and personal standard.

[url=http://www.ericis.com/Posts/default.aspx?id=184]Read my blog post for details.[/url]

Eric Swanson
http://www.ericis.com/
Go to Top of Page

ericis_com
Starting Member

USA
2 Posts

Posted - 05/10/2006 :  15:19:22  Show Profile  Visit ericis_com's Homepage  Reply with Quote
I have personally struggled with this for a long time, but recent enlightenment has given me a new perspective and personal standard.

[url=http://www.ericis.com/Posts/default.aspx?id=184]Read my blog post for details.[/url]

Eric Swanson
http://www.ericis.com/
Go to Top of Page

fxtrader
Starting Member

1 Posts

Posted - 10/09/2006 :  17:58:34  Show Profile  Reply with Quote
quote:
Originally posted by RocketScientist

I've got to disagree with some of the article.

Table names should always be singular. Because (1) I said so and (2) because you end up with things like the article's example: TerritoriesManagers. Yick. Asthetically not pleasing.



I'm with you on this. The idea that the row of a table represents an entity - and that having multiple rows implies the table name should be plural - is not really correct. The table definition taken as a whole is a logical representation of an abstract entity, for example 'customer'. The rows in the table aren't the abstraction (object) but the concept of 'customer' is the abstraction. The rows in the table really have nothing to do with the abstraction. The entity we're representing is not 'Customers' but 'customer'. Put another way, whether I have one customer - and am out of business :( or many customers, the abstraction is still 'customer' and singular. And the abstraction is what's important for oo programming.

Therefore, in my opinion, the singular word is more appropriate to affix as the title of our logical representation of the abstraction - the table. In this way, we've taken a nice step toward our oo system design.

This aside, what Rocketscientist said about concatenating plural table names is right on. It is not natural and frankly, I've been programming db's a long time and can't recall a published book showing it that way or a large database structure with that naming convention being chosen.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.28 seconds. Powered By: Snitz Forums 2000