If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Naming conventions

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-22-07, 15:06
starkmann starkmann is offline
Registered User
 
Join Date: Feb 2007
Posts: 348
Naming conventions

I read the Access Ten Commandments today:
http://www.mvps.org/access/tencommandments.htm

forgive my noobish glow but, and recommendations on naming conventions? I have typically tried to use Nametbl, Nameqry, Namefrm, Namerpt and try to name things along the same lines, like Issue table for the primary table of my app, Issueqry for the query that brings together the lookups with the Issuetbl. Issuefrm would probably look at that and last Issuerpt for the big report with everything. Then as I add criteria I tend to add that to the name, like IssueOpenByUserrpt and so on.
Thoughts, crticisms, ideas?

I'm off to try an look up DB splitting now.
Reply With Quote
  #2 (permalink)  
Old 05-22-07, 20:01
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
naming conventions are great, as is plainly evidenced by how many of them there are

if you have a naming convention, use it -- it will be a great comfort to you if you have to maintain your own code, and it might even help someone else if they have to maintain your code after you're gone
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 05-23-07, 10:38
starkmann starkmann is offline
Registered User
 
Join Date: Feb 2007
Posts: 348
Fair enough. So 'almost' anything works as long as you stick to it like glue, eh.
Reply With Quote
  #4 (permalink)  
Old 05-23-07, 10:58
blindman blindman is offline
World Class Flame Warrior
 
Join Date: Jun 2003
Location: Ohio
Posts: 11,726
No spaces in object names.
Use CamelBackStyle rather than underscore_style.
Don't use object type prefixes such as "sp", "tbl", or whatever.
Eschew Acronyms.
Name your objects so that your SQL statements read like sentences.
__________________
If it's not practically useful, then it's practically useless.

blindman
www.chess.com: "sqlblindman"
Reply With Quote
  #5 (permalink)  
Old 05-23-07, 11:01
starkmann starkmann is offline
Registered User
 
Join Date: Feb 2007
Posts: 348
Quote:
Originally Posted by blindman
Name your objects so that your SQL statements read like sentences.
Oh, that one seems like a really good one. They're all good but that one is one I hadn't thought of, yet so obvious
Reply With Quote
  #6 (permalink)  
Old 05-23-07, 11:08
msmeland msmeland is offline
Registered User
 
Join Date: Mar 2004
Location: Between Chicago and Milwaukee
Posts: 187
UnlessOfCourseYouAreParticuallyVerboseAndHaveATend ancyToOverexplainEverything.
__________________
"An adventure is only an inconvenience rightly understood; an inconvenience is only an adventure wrongly considered." ~G.K. Chesterton
Reply With Quote
  #7 (permalink)  
Old 05-23-07, 11:12
starkmann starkmann is offline
Registered User
 
Join Date: Feb 2007
Posts: 348
Quote:
Originally Posted by msmeland
UnlessOfCourseYouAreParticuallyVerboseAndHaveATend ancyToOverexplainEverything.
IAmGuiltyOfThatPrettyOften

Reply With Quote
  #8 (permalink)  
Old 05-23-07, 11:40
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Quote:
Originally Posted by starkmann
...as long as you stick to it like glue, eh.
no way

you want to be able to unstick yourself from it painlessly, should it turn out, in retrospect, to be silly

you know, like naming all your tables with 'tbl' as the first three characters
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #9 (permalink)  
Old 05-24-07, 07:07
starkmann starkmann is offline
Registered User
 
Join Date: Feb 2007
Posts: 348
stupid question but a couple of you mentioned not naming your items with a prefix. I don't but why is that so bad? You have to read four more characters to see what you are talking about but is there something more I am missing?
Reply With Quote
  #10 (permalink)  
Old 05-24-07, 07:31
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
"nounParis prepIn artThe nounSpring"

the prefixes sure make it easier to read, don't they

props to Joe Celko
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #11 (permalink)  
Old 05-24-07, 07:49
starkmann starkmann is offline
Registered User
 
Join Date: Feb 2007
Posts: 348
lol fair play there.

That guy has a cool site w/ the SQL puzzles and all.Bookmarked.
Reply With Quote
  #12 (permalink)  
Old 05-24-07, 20:21
certus certus is offline
Registered User
 
Join Date: Dec 2003
Location: Canada
Posts: 710
There is a naming convention by the International Standards Organization. Check out 11179-5 under ISO 11179
__________________
visit: relationary

Last edited by certus; 05-24-07 at 20:30.
Reply With Quote
  #13 (permalink)  
Old 05-24-07, 21:23
starkmann starkmann is offline
Registered User
 
Join Date: Feb 2007
Posts: 348
now that is really cool. I have to admit, I have basically skimmed at this point but I want to come back to it. Most of what I have seen is pretty common sense but with a little structure thrown in.
Reply With Quote
  #14 (permalink)  
Old 05-28-07, 23:10
sco08y sco08y is offline
Registered User
 
Join Date: Oct 2002
Location: Baghdad, Iraq
Posts: 697
Quote:
Originally Posted by starkmann
stupid question but a couple of you mentioned not naming your items with a prefix. I don't but why is that so bad? You have to read four more characters to see what you are talking about but is there something more I am missing?
In SQL it really doesn't tell you much. Table names can only go in certain places, likewise with attribute names. That's the benefit of the complex syntax.

The practice probably came from C programmers. In C there's no way to tell if a variable is a "long" or a "short" integer and you can get into all sorts of trouble if you get them mixed up. And C allows you to have global variables strewn all over your project.

SQL can have the same problem, especially since CHAR(40) is a different type than CHAR(30), but it's mitigated to a large extent because all the type definitions being in the schema. You can still run into problems with temporary variables in triggered procedures, but it's nowhere near as bad as C.

I do use prefixes in one case: sometimes I group sets of related columns when it's a particularly wide table. In this case, it makes sense, to me at least, to deliniate these groups with prefixes. You can also plan ahead by creating queries that split the table up for you, e.g.

Code:
CREATE TABLE LotsOfColumns (
  primaryKey INTEGER PRIMARY KEY,
  namFirstName CHAR(),
  namLastName CHAR(),
  homStreet CHAR(),
  homCity CHAR(),
  homZIP CHAR(),
  wrkStreet CHAR(),
  wrkCity CHAR(),
  wrkZIP CHAR()
);

CREATE VIEW Names AS
SELECT primaryKey, namFirstName as firstName, namLastName as LastName
FROM LotsOfColumns;

CREATE VIEW  HomeAddys AS
SELECT primaryKey, homStreet as street, homCity as city, homZIP as ZIP
FROM LotsOfColumns;
Reply With Quote
  #15 (permalink)  
Old 05-29-07, 04:28
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Just another ingredient in the pot (since the thread is entitled "Naming conventions, here's another for you!) ...
I unfortunately have to program in FoxPro a fair amount and the naming conventions in there have to be one of it's only good features
Each variable is prefixed with 2 characters

1st Character:
l = local
p = public

2nd Character:
n = number
c = character
b = boolean
etc etc...
__________________
George
Twitter | Blog
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On