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

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

    Use natural keys whenever they work. Names usually don't work. They are too mutable.

    If you are inventing your own data, you might as well invent a syntheic key. If you are building a database of data provided by other people or their software, analyze the source data to see how they identify things that need identification.

    If they are managing data at all well, they will have natural keys that work for the important stuff. For the unimportant stuff, suit yourself.

提交回复
热议问题