What's the best practice for primary keys in tables?

前端 未结 21 2479
别那么骄傲
别那么骄傲 2020-11-22 14:02

When designing tables, I\'ve developed a habit of having one column that is unique and that I make the primary key. This is achieved in three ways depending on requirements

21条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 14:24

    I always use an autonumber or identity field.

    I worked for a client who had used SSN as a primary key and then because of HIPAA regulations was forced to change to a "MemberID" and it caused a ton of problems when updating the foreign keys in related tables. Sticking to a consistent standard of an identity column has helped me avoid a similar problem in all of my projects.

提交回复
热议问题