• ScottPletcher (10/6/2015)


    Ed Wagner (10/6/2015)


    I like the convention child_parent_PK

    Where:

    child = Name of the table with the foreign key

    parent = Name of the table with the primary key being referred to

    _PK = constant

    For example, if I have an Orders table that has a foreign key to Customers, the foreign key constraint would be named Orders_Customers_PK.

    If you have a table with multiple foreign keys to a single table, adjust the name as necessary by adding something else about the foreign key.

    I think the important point is that you have some convention, no matter what it is. As long as it makes sense to you and others in your organization, that's what's most important.

    Hmm. Seems odd to me that a FK would have "_PK" in the name. Esp. as now a fk can reference any unique index, not just specifically a PK.

    Heh - Good catch, Scott. You're exactly right. I should have typed _FK instead of _PK. Hey, at least I was consistent in my typos. 😛

    I use the suffix _PK for primary key constraints, _FK for for foreign key constraints and _UQ for unique constraints.