0

So the question is self explanatory. And I promise I check for similar question. like this : question or this : question have to say I already read mysql manual, and I know that PK is null and unique.

I was looking at moodle's users table for example and they just have checked PK an NN field, is this a secure assignment for a user id value? while in other databases they have both PK and UQ checked. Please let me know if you have found any reason to have both checked or you think is redundant.

If at some point you found something additional in case like use this fields as foreign keys or any other thing I miss. please let me now your experience. I would accept the answer which contain extra information from the mysql manual rather than on it.

Thanks in advance.

Community
  • 1
  • 1
Mik
  • 105
  • 1
  • 10
  • A primary key is unique **by definition**. If a column is defined as a primary key, the database engine automatically creates a unique index on that column. – Zohar Peled Jun 07 '16 at 07:29

1 Answers1

0

A primary key is also a unique key but not viceversa. See this question difference between key typos

So it is redundant to add a unique constraint on a primary key.

Community
  • 1
  • 1
Aris2World
  • 1,214
  • 12
  • 22