I read somewhere, saying that every table must have a primary key to execute 1NF.
I have a tbl_friendship table.
The table has 2 fields: "Owner and friend."
The owner and friend fields are foreign keys of the auto increment id field in tbl_user.
Should this tbl_friendship have a primary key? Should I create an auto increment id field in tbl_friendship and make it primary?
! , (Owner, Friend). , " " , (, "", (OwnerId, FriendId)
, , , .
, . http://michaeljswart.com/2011/01/ridiculously-unnormalized-database-schemas-part-zero/
, .
, .. aka auto increment pk field.
"Friend" FK .
, " ", , , , , . , , . , , , ux , .
, , .
, , ? .
( , ). .
. (, ), . ( "", "" ) , , . , , . , , .
, , (, MySQL) Oracle.
1NF ( , 1NF), , , . .
http://en.wikipedia.org/wiki/First_normal_form
, , , , - GUID, - , , .
In the long run, your table will be much easier to manage if it has a primary key. At least you need to uniquely identify each record in the table. A field that is used to uniquely identify each record can also be a primary key.
Yes, each table must have (at least one) key. Duplication of rows in any table is undesirable for many reasons, so set a limit on these two columns.