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

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

    You should probably always use an ID number (that way if you change the type name, you don't need to update the user table) it also allows you to keep your datasize down, as a table full of INTs is much smaller than one full of 45 character varchars.

提交回复
热议问题