• Grant Fritchey (1/23/2009)


    timothyawiseman (1/22/2009)


    I'll agree with Grant, though there are some cases where it makes sense to have a column named Id in the base table and then the foreign keys referencing it may be named BasetablenameId.

    In general, it should be very obvious through names alone what the relations are.

    I've seen those designs. I've never been crazy about them. If you query more than one table and want to return the PK you then have to alias the PK names in the queries... It seems really sloppy to me. Worse yet, it requires extra work and I am lazy.

    I prefer naming something what it is and letting that thing live that way through the database and, if possible, throughout the enterprise.

    You have a good point, but it makes for consistency in the naming of the primary key and that can make certain things easier, especially when working with certain 3rd party tools for Linq.

    ---
    Timothy A Wiseman
    SQL Blog: http://timothyawiseman.wordpress.com/