Tech Off Thread

8 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Table/Stored Procedure naming conventions

Back to Forum: Tech Off
  • User profile image
    LostIn​Tangent

        In line with w3bbo's thread on form control naming conventions, I'm curious as to what conventions you all follow when it comes to naming your database tables and stored procedures.

    1) Do you name your tables singluar or plural?
    2) Do you prefix your table names with anything?
    3) Do you name your stored procedures based on the table they are associated with or by the domain they reside in?
    4) What do you prefix your stored procedures with?
    5) ect.

    I've seen just about everything done, and am interested to see what some of the bigger brains of Channel9 have been doing.

  • User profile image
    Sven Groot

    I name tables singularly. I use the same conventions for naming functions and sprocs as I do for functions, so Verb-Noun. If I need to store multiple completely unrelated things in a single database (you don't usually get the luxury of multiple databases on a shared server) I will prefix them based on that. Auto-generated stored procedures are postfixed using "_gen".

    W3bbo wrote:
    I don't know why Verb-Noun is so popular when it's better to use Noun-Verb.

    Why are they better? Any technical reason? Or did you just mean you like it better which is a completely different thing and means absolutely nothing to anyone else.

  • User profile image
    AndyC

    W3bbo wrote:
    
    I don't know why Verb-Noun is so popular when it's better to use Noun-Verb.

    Readability. It makes the code read closer to the way you'd say it (assuming you aren't Yoda)

  • User profile image
    LostIn​Tangent

    I prefer the Verb-Noun syntax as well. I also prefer plural table names because it seems more consistent with the way you would name a collection or list in your code (and a table is like a collection of rows). It seems to lend itself well to keeping harmony throughout the application.

    As far as prefixes, I definitely agree with the reasoning on why they aren't neccesary. But many would argue that it's not so much the seperation of the objects that causes the need for a prefix, but the distinction in your SQL. So if you have a stored procedure that is querying a table or a view, it would be apparent. I personally don't agree with it, but its a pretty prevalent method.

  • User profile image
    W3bbo

    Since most DBA tools worth their salt seperate Sprocs, Views, Functions, and Tables there's no need to prefix them.

    I name tables plurally "Users"/"Customers" and name Sprocs using German syntax: Noun-Verb ("UserGet", "CustomersList", "AccountDelete")

    I don't know why Verb-Noun is so popular when it's better to use Noun-Verb.

    EDIT: And as Sven pointed out, often you're limited to one database so I prefix my tables and sprocs with some sort of application-specific identifier.

  • User profile image
    Buzza

    Noun-Verb are better because the group the functions based on the type of function they are:

    CustomerGet
    CustomerDelete
    CustomerStore
    etc.

    The dev tools will usually list in alpha order Wink

  • User profile image
    blowdart

    Buzza wrote:


    The dev tools will usually list in alpha order Wink


    Which is why I use entityVerb.

    Noun. Pah!

  • User profile image
    littleguru

    Plural without prefix. The name in plural because a table contains not only one record, but usually a set of records. No prefix, because it's not needed.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.