Tables with no Primary Key

后端 未结 7 1670
一个人的身影
一个人的身影 2020-12-13 00:17

I have several tables whose only unique data is a uniqueidentifier (a Guid) column. Because guids are non-sequential (and they\'re client-side generated so I can\'t use news

7条回答
  •  借酒劲吻你
    2020-12-13 00:53

    A Primary Key needn't be an autoincrementing field, in many cases this just means you are complicating your table structure.

    Instead, a Primary Key should be the minimum collection of attributes (note that most DBMS will allow a composite primary key) that uniquely identifies a tuple.

    In technical terms, it should be the field that every other field in the tuple is fully functionally dependent upon. (If it isn't you might need to normalise).

    In practice, performance issues may mean that you merge tables, and use an incrementing field, but I seem to recall something about premature optimisation being evil...

提交回复
热议问题