0
why use primary keys ?
7 Antworten
+ 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.
+ 6
To prevent duplicates.
+ 4
How else would you JOIN stuff? :)
+ 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
0
i am new to this
0
say clearly
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