Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Naming Convention

Author  Topic 

Tristan.Wolf
Starting Member

5 Posts

Posted - 2006-05-08 : 19:30:15
Would like to know what naming convention you folks use.

What I need specifically is column naming conventions.

For instance, I have a table called 'lst_as400_srvr'. We could go with the vigorous:

CREATE TABLE lst_as400_srvr
(
as400_srvr_id int NOT NULL IDENTITY,
as400_srvr_name varchar(128) NOT NULL,
as400_srvr_is_active bit NOT NULL DEFAULT 1
)


Or, I could loosen the rules a bit and go with:

CREATE TABLE lst_as400_srvr
(
id int NOT NULL IDENTITY,
name varchar(128) NOT NULL,
is_active bit NOT NULL DEFAULT 1
)


I would lean towards the vigorous because it would be very obvious what data is being referenced by the name. In the loosened version, I could very easily have many tables with a 'id' column or a 'is_active' column.

Inversely, I would lean towards the loosened version because the names are a lot shorter and, thus, easier / faster to type.

I figure, if I'm going to learn a new standard, now's a good time to do so.

So, thoughts? Appreciate the help folks. :)

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-05-08 : 19:37:33
We use TableName_ID for our identity columns. We do not use id or name as both are reserved words. So make them more descriptive. I prefer camel case as opposed to underscores. But whichever you use, IsActive or is_active doesn't need the table name associated to it.

Tara Kizer
aka tduggan
Go to Top of Page

MichaelP
Jedi Yak

2489 Posts

Posted - 2006-05-08 : 19:45:45
+1 to what Tara said.
You shouldn't have fields like Name, ID, or Description because they are reserved words. A column called ID is going to need to be aliased if you do a join anyway, so why not give it a more descriptive name, like TableNameID or TableName_ID. I like to use camel case instead of underscores because underscores are harder to type for me.

Michael

<Yoda>Use the Search page you must. Find the answer you will. Cursors, path to the Dark Side they are. Avoid them, you must. Use Order By NewID() to get a random record you will.</Yoda>

Opinions expressed in this post are not necessarily those of TeleVox Software, inc. All information is provided "AS IS" with no warranties and confers no rights.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-05-09 : 00:01:08
See: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=55210&SearchTerms=Good+table+naming+convention (and the link to naming Sprocs underneath)

Kristen
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-05-09 : 00:58:56
http://vyaskn.tripod.com/object_naming.htm

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

RyanRandall
Master Smack Fu Yak Hacker

1074 Posts

Posted - 2006-05-10 : 06:15:06
Aren't any of you worried about having non-normalised system tables?

Ryan Randall
www.monsoonmalabar.com London-based IT consultancy

Solutions are easy. Understanding the problem, now, that's the hard part.
Go to Top of Page
   

- Advertisement -