Primary Key versus Unique Constraint?

前端 未结 16 1910
轮回少年
轮回少年 2020-12-13 03:49

I\'m currently designing a brand new database. In school, we always learned to put a primary key in each table.

I read a lot of articles/discussions/newsgroups posts

16条回答
  •  执念已碎
    2020-12-13 04:30

    It would be very rare denormalization that would make you want to have a table without a primary key. Primary keys have unique constraints automatically just by their nature as the PK.

    A unique constraint would be used when you want to guarantee uniqueness in a column in ADDITION to the primary key.

    The rule of always have a PK is a good one.

    http://msdn.microsoft.com/en-us/library/ms191166.aspx

提交回复
热议问题