I know this is a very basic concept and I predominantly understand the purpose of a Primary Key and a Foreign Key. But as I've been learning the concept of a Unique Key came up and I was unable to find a resource that gives me a clear understanding of the purpose of a Unique Key. I would love it if someone co explain the difference while comparing it to Primary and Foreign Keys potentially with some examples if applicable.
Discussion posts and replies are publicly visible
Primary Key :
Example :
In the below STUDENT table "Roll_Number" is the Primary Key of the table. This Roll_Number can be used to uniquely identify the rows of a STUDENT table.
Unique Key :
Example : In the above table, we have Phone_Number as the Unique Key and Roll_Number as the Primary Key. If any student has a Phone_Number then it should be unique. Also, there might be some student who doesn't have any Phone_Number. In the table the Student Scott do not have a Phone Number.
Note :
Foreign Key :