Relational database design question - Surrogate-key or Natural-key?

前端 未结 10 2154
忘了有多久
忘了有多久 2020-11-27 22:33

Which one is the best practice and Why?

a) Type Table, Surrogate/Artificial Key

Foreign key is from user.type to type.i

10条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-27 23:29

    Surrogate key is a substitution for the natural primary key. It is just a unique identifier or number for each row that can be used for the primary key to the table. The only requirement for a surrogate primary key is that it is unique for each row in the table.

    It is useful because the natural primary key (i.e. Customer Number in Customer table) can change and this makes updates more difficult.

提交回复
热议问题