When we don't need a primary key for our table?

后端 未结 4 816
無奈伤痛
無奈伤痛 2021-02-04 10:06

Will it ever happen that we design a table that doesn\'t need a primary key?

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-04 10:47

    Yes.

    If you have a table that will always be fetched completely, and is being referred-to by zero other tables, such as some kind of standalone settings or configuration table, then there is no point having a primary key, and the argument could be made by some that adding a PK in this situation would be a deception of the normal use of such a table.

    It is rare, and probably when it is most often done it is done wrongly, but they do exist, and such instances can be valid.

提交回复
热议问题