Naming of ID columns in database tables

后端 未结 23 747

I was wondering peoples opinions on the naming of ID columns in database tables.

If I have a table called Invoices with a primary key of an identity column I would c

23条回答
  •  温柔的废话
    2020-11-29 18:06

    I agree with Keven and a few other people here that the PK for a table should simply be Id and foreign keys list the OtherTable + Id.

    However I wish to add one reason which recently gave more weight to this arguement.

    In my current position we are employing the entity framework using POCO generation. Using the standard naming convention of Id the the PK allows for inheritance of a base poco class with validation and such for tables which share a set of common column names. Using the Tablename + Id as the PK for each of these tables destroys the ability to use a base class for these.

    Just some food for thought.

提交回复
热议问题