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

前端 未结 10 2153
忘了有多久
忘了有多久 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:21

    The first one is more future proof, because it allows you to change the string representing the type without updating the whole user table. In other words you use a surrogate key, an additional immutable identifier introduced for the sake of flexibility.

提交回复
热议问题