Home All Groups Group Topic Archive Search About

Standard naming convention for index and triggers?

Author
28 Jul 2006 10:28 PM
tshad
Is there a standard naming convention (best practice) for indexes, triggers
and keys?

I've seen indexes as:

Table name + Column name(s) + Unique/Non-uniqueness +
Clustered/Non-clustered

   OrderDetails_OrderIDOrderDetailID_U_Cidx

This is fine if it is only one column, but what if their are multiple
columns (3 or more).  This would make the name pretty large.

Also, I am not a fan of underscores in a name (but I do use them in some
cases).

Triggers:

titles_instrg
titles_updtrg
titles_deltrg


Keys I have seen as:

    pk_Customers_CustomerID
    fk_OrdersCustomerID_CustomersCustomerID

None of the books I have looked at really talk about it.  I found these on a
web page for naming conventions.  But this is just one opinion.

Thanks,

Tom

Author
28 Jul 2006 10:44 PM
Roy Harvey
On Fri, 28 Jul 2006 15:28:00 -0700, "tshad"
<tscheider***@ftsolutions.com> wrote:

>Is there a standard naming convention (best practice) for indexes, triggers
>and keys?
>
>I've seen indexes as:
>
>Table name + Column name(s) + Unique/Non-uniqueness +
>Clustered/Non-clustered
>
>   OrderDetails_OrderIDOrderDetailID_U_Cidx
>
>This is fine if it is only one column, but what if their are multiple
>columns (3 or more).  This would make the name pretty large.

I don't spend much time looking at indexes by name.  I just use
TableName_columns, but I am willing to abbreviate and otherwise
compromise the columns part.  I do want indication of clustered or
unique, as I want to get that information from a difninitive source,
not assume a name is correct.

>Also, I am not a fan of underscores in a name (but I do use them in some
>cases).

I don't much care for them, but that means that when I DO use them it
is a significant break point, as in table name vs index columns

>Triggers:
>
>titles_instrg
>titles_updtrg
>titles_deltrg

I juse use TableName_IUD, with whatever subset of IUD (Insert, Update,
Delete) fits that particular trigger.  If I ever end up with multiple
triggers I will just add whatever suffix seems natural.

>Keys I have seen as:
>
>    pk_Customers_CustomerID
>    fk_OrdersCustomerID_CustomersCustomerID

In violation of all the Right Thinking and Acting folks here, I just
let the system give them names.

>None of the books I have looked at really talk about it.  I found these on a
>web page for naming conventions.  But this is just one opinion.

And mine is just one more opinion.

Roy Harvey
Beacon Falls, CT

AddThis Social Bookmark Button