What is the difference between primary key and super key? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the difference between primary key and super key?

28th Nov 2016, 12:39 PM
shilpa
shilpa - avatar
5 Answers
+ 4
Primary Key: Primary key is the columns you choose to maintain uniqueness of each colume in a table. Like EmployeeID or student roll number can be use as primary key. Here student roll number is unique for a particular class. No two student can have same roll no in same class. As employeeID for a company is unique. 4. Super Key: If you add any other column/attribute to a Primary Key then it become a super key, like EmployeeID + FullName is a Super Key. And if there is more than one class data is stored on same table, then to make uniqueness of colume then you can use class id + student roll no. And this is called a super key. Hope you understand, for more comment
28th Nov 2016, 1:20 PM
Aditya kumar pandey
Aditya kumar pandey - avatar
+ 3
Think about a student table having name, roll number, age,class_id. student{ int roll_number , age, class_id; VARCHAR name; primary key (roll_number, class_id) } And this code description is given in my pervious example. Remember this code is not that valid because syntax error. But to create a primary key is correct. You can use it.
28th Nov 2016, 2:12 PM
Aditya kumar pandey
Aditya kumar pandey - avatar
0
I need a good example for super key
28th Nov 2016, 1:40 PM
shilpa
shilpa - avatar
0
ty aditya
28th Nov 2016, 2:51 PM
shilpa
shilpa - avatar
0
Minimal column which are sufficient to identify row is primary key. Super keyalso use for identify row but one super key may be contain more than 1 primary key or combination of primary keys known as super key. Both used for uniquely identify of row. Table contain more than 1 candidate key but only 1 primary key.
28th Nov 2016, 5:25 PM
Abdelaziz Abubaker
Abdelaziz Abubaker - avatar