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

前端 未结 11 1834
感动是毒
感动是毒 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:05

    Every table should have a primary key. But it doesn't need to be a single field identifier. Take for example in a finance system, you may have the primary key on a journal table being the Journal ID and Line No. This will produce a unique combination for each row (and the Journal ID will be a primary key in its own table)

    Your primary key needs to be defined on how you are going to link the table to other tables.

提交回复
热议问题