Are there any good reasons to have a database table without an integer primary key?

前端 未结 11 1835
感动是毒
感动是毒 2021-02-10 00:30

Although I\'m guilty of this crime, it seems to me there can\'t be any good reason for a table to not have an identity field primary key.

Pros: - whether you want to o

11条回答
  •  南笙
    南笙 (楼主)
    2021-02-10 01:11

    One reason not to have primary key defined as identity is having primary key defined as GUIDs or populated with externally generated values.

    In general, every table that is semantically meaningful by itself should have primary key and such key should have no semantic meaning. A join table that realizes many-to-many relationship is not meaningful by itself and so it doesn't need such primary key (it already has one via its values).

提交回复
热议问题