2

Can two tables have the same primary keys?

For instance:

two tables with the same primary keys

Revolucion for Monica
  • 679
  • 1
  • 10
  • 27

1 Answers1

1

Yes. This is a common scenario when implementing 0..1 relationships.

Ezequiel Tolnay
  • 5,008
  • 1
  • 16
  • 23
  • 1
    I guess you mean 1-1 relationships – ypercubeᵀᴹ May 05 '16 at 08:40
  • @ypercubeᵀᴹ 1..1 relationships are impossible in practice, at least on a current RDBMS. In a 0..1 relationships, those that have the same PK, the one that gets the 0 is the one that implements the foreign key. – Ezequiel Tolnay May 05 '16 at 08:47
  • 3
    OK, we mean the same thing. I just have seen (what you note as 0..1) to be noted as 0..1 - 1 and the strict 1-1 to be noted as 1-1 (and in general, all of them to be called one-on-one). I know that strict 1-1 is difficult - but not impossible, even with DRI only. You only need deferrable constraints, which are available in Postgres (and Oracle if I am not wrong). – ypercubeᵀᴹ May 05 '16 at 08:49