I have a table user and a table user_statistic with a one to one (1:1) relationship.

Note that we have an identifying relationship between user and user_statistic.

Which is best practice for user_statistic primary key ?

  • Use an auto increment id as primary key
  • Use the user foreign key as primary key
  • Use both as a composite primary key (feels like a bad idea but in an identifying relationship, foreign key must be part of the primary key...)
  • 3
    In any case, I suggest you use option 2. No extra auto-increment needed. – ypercubeᵀᴹ Jun 14 '18 at 9:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.