0

Both are valid, but which one should be used when?

Here's a little example:

Case of AlarmProfileID as prime key

enter image description here

Case of composite key consisting of {username and name}

enter image description here

Thorsten Kettner
  • 89,309
  • 7
  • 49
  • 73
aryan
  • 130
  • 1
  • 8
  • 1
    *Both are valid, but which one should be used when?* Formally both are valid, this is correct. But they describes two different systems. You have only one system - so you must select those scheme which is adequate to your system.. and it is possible that none of them matches. – Akina Jun 07 '23 at 16:23
  • 1
    I see what you're saying. In the first case a user can have multiple alarmProfiles with the same name, but in the second case it can't. Thanks! – aryan Jun 07 '23 at 16:25
  • 1
    Some years ago I gave this answer: https://stackoverflow.com/a/31380909/2270762 when asked when to use composite keys. It is rather long, but thorough. Maybe you find the answer you are looking for in that explanation. – Thorsten Kettner Jun 07 '23 at 17:41

0 Answers0