When not to use surrogate primary keys?

后端 未结 6 1293
鱼传尺愫
鱼传尺愫 2020-12-06 06:09

I have several database tables that just contain a single column and very few rows, often just an ID of something defined in another system. These tables are then reference

6条回答
  •  心在旅途
    2020-12-06 07:00

    I'm not sure there's an exception case when surrogate keys shouldn't be used. I think that the nature of a surrogate key, generally to make a reference globally unique, is particularly relevant when applied to a system such as you describe.

    While each of the satellite primary keys you mention may be unique within their own scope, you can't really guarantee that they will remain unique across the whole scope of your interconnected environment, especially if it expands. I suspect the original designers were either trying to future proof their system or riding the latest fad they'd learnt ;)

提交回复
热议问题