The 365 Data Science team is proud to invite you to our own community forum. A very well build system to support your queries, questions and give the chance to show your knowledge and help others in their path of becoming Data Science specialists.
Ask
Anybody can ask a question
Answer
Anybody can answer
Vote
The best answers are voted up and moderated by our team

primary key

primary key

Super Learner
0
Votes
1
Answer

What is the difference between primary key and unique key ?

1 Answer

365 Team
0
Votes

Hi Karan!
Thanks for reaching out!
Unique key means that the values within that column are unique. You can have 1, 2, 3 or more fields whose values are unique, and that’s why you can have 0, 1, 2, 3 or more unique keys.
Primary keys have another function – to uniquely identify each record in a table. You can have only one such column/field, and it will be your primary key.
Hence, it is logical that a primary key is a type of unique key itself. But there can be only one primary key (regardless of whether it has been composed of only one column, or of many columns), that identifies each record in a table uniquely.
So, you can think of a primary key as a unique key that has the task to uniquely identify each record in a table.
Also, primary and unique keys cannot share fields. Among the various constraints that could apply to a specific field, the primary key and the unique key constraint potentially are two exclusive options.
Hope this helps.
Best,
Martin

Thanks!

3 weeks