Results 1 to 14 of 14
  1. #1
    Join Date
    Sep 2002
    Posts
    18

    Naming Convention

    Can someone help on naming conventions.

    What do you guys/gals do for naming databases, tables, queries, etc?

    Thx

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    I name them what they are.
    No prefixes, please....
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  3. #3
    Join Date
    Sep 2002
    Posts
    18
    Ok gr8, no prefixes.

    How about capitalization?

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by oozypal
    How about capitalization?
    bad idea -- name everything in lower case
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    captalisation can cause problems especially if you are working in a mixed Microsoft/Linux environment, some advocate not to use capitals but to capitalise the SQL eg SELECT my, column, list FROM mytable

    theres numerous naming conventions out there. some peopel try to apply the Simonyi style notation (eg strThis, intThat and so on).. I'd argue there is no requirement to do so within the tables, within your application code its probably a good idea especiallyif you are using

    Personally I prefer capitalising eg MyVariable, rather than myvariable.. for me its easier on the eye, easier to read. some advocate underscore eg tel_no, which I just think is ugly

    however the one thing you can say on naming conventions is be consistent. if there is already a naming convention use it.

    another thing to bear in mind as part of your convention is common abbreviations and perhaps just as importantly give column & table names a consistent name

    eg TelNo in place of TelephoneNumber.. so NUmber should always be abbreviated in the same manner
    Address is Addr and so on

    some give the table name a plural eg you'd have a table products, rather than product

    but be aware of any reserved words such as Desc, Name, Integer Date and so on.

    style generic columns as say ID (for numbers), Type for text/char, dont include the table name eg in a table called products don't have a column called ProductID, have one called ID. if you prefer use ProductID where that value is acting as a FK to the ID in Products

    But ultimately pick one that exists or develop one that meets your style and your requirememnt

    frankly I suspect some of the naming conventions are more to do with individuals ego at seeing their name associated with a specific naming convention. it doesn't matter what you use, the real advantage of using a convention is that its easier to pick up your own work at a later date, or pick up someoone else's work.
    I'd rather be riding on the Tiger 800 or the Norton

  6. #6
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Quote Originally Posted by r937
    name everything in lower case
    ++1 .
    George
    Home | Blog

  7. #7
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Quote Originally Posted by r937
    bad idea -- name everything in lower case
    Seriously? I use CamelCase for readability.
    CamelCase - Wikipedia, the free encyclopedia

    But the, you're just going to alias the crap out of everything anyway, so what do you care what its real name is?
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  8. #8
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by blindman
    Seriously?
    yes, seriously

    i'm guessing you've never used a non-microsoft operating system?

    i mean, camel case is fine, don't misunderstand, i like it, but it's nothing to build a convention on, much less "best practice"

    and aren't you the guy who disdains aliases?

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  9. #9
    Join Date
    Dec 2007
    Location
    London, UK
    Posts
    741
    If you use mixed case then use tools that let you develop and test in a case-sensitive manner.

    This is possible in Microsoft environments too. Even SQL Server 2008 has intellisense with auto-completion. In SQL Server you can make names case-sensitive and in C# they are by default.

  10. #10
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    I prefer case insensitive. The CamelCase is for my benefit, not the server's or the application's.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  11. #11
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by blindman
    The CamelCase is for my benefit, not the server's or the application's.
    pffffffffft!!! you're just the DBA, wtf do you know

    ask your developers what they prefer

    you might be surprised

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  12. #12
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Quote Originally Posted by r937
    pffffffffft!!! you're just the DBA, wtf do you know

    ask your developers what they prefer

    you might be surprised

    I'm sorry. Are you referring to the bootlickingtoadies, or the BootLickingToadies?
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  13. #13
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    OK, I just asked all my developers, and they prefer CamelCase, saying that all lower case is difficult to read.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  14. #14
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    lower_case_separated_by_underscores

    George
    Home | Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •