why use primary keys ? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

why use primary keys ?

28th Jul 2017, 3:37 PM
Jagan Jagan
Jagan Jagan - avatar
7 ответов
+ 7
@Bogdan Oh, sure, of course you can, theoretically. But in order to be sure of your data accuracy you usually have to have unique values in your "rows" as "matching partners" - a primary key and a foreign key as its partner.
28th Jul 2017, 4:24 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 6
To prevent duplicates.
28th Jul 2017, 6:46 PM
Koketso Dithipe
Koketso Dithipe - avatar
+ 4
How else would you JOIN stuff? :)
28th Jul 2017, 3:42 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 1
You need them to identify uniquely each row imagine talking with another person, you want him to tell you the surname of "Tom" in your table with thousands names. He would say "which Tom? there are hundreds of Tom in this table!" But with a primary key you can say "Tell me the surname of the person with ID=735" There is only ONE person with that ID, so he will immediately find it
28th Jul 2017, 3:56 PM
Matte
Matte - avatar
0
i am new to this
28th Jul 2017, 3:43 PM
Jagan Jagan
Jagan Jagan - avatar
0
say clearly
28th Jul 2017, 3:43 PM
Jagan Jagan
Jagan Jagan - avatar
0
@kuba - I don't get it... You can JOIN on any field, including fields that are not primary keys... @jagan: https://www.w3schools.com/sql/sql_primarykey.asp
28th Jul 2017, 3:52 PM
Bogdan Sass
Bogdan Sass - avatar