Composite primary key

前端 未结 8 1545
旧巷少年郎
旧巷少年郎 2020-12-15 18:37

I am working on the design of a database that will be used to store data that originates from a number of different sources. The instances I am storing are assigned unique I

8条回答
  •  无人及你
    2020-12-15 19:09

    I ran into problems using a lot of composite keys and so I wouldn't recommend it (more below), I've also found there to be benefits in an independent/surrogate key (rather than natural) when trying to roll back user mistakes. The problem was that via a set of relations, one table joined two tables where for each row part of the composite was the same (this was appropriate in 3rd normal form - a comparison between two parts of a parent). I de-duplicated that part of the composite relationship in the join table (so instead of parent1ID, other1ID, parent2ID, other2ID there was parentID, other1ID, other2ID) but now the relation couldn't update changes to the primary key, because it tried to do it twice via each route and failed in the middle.

提交回复
热议问题