Single Field primary key
MySQL single field primary key I believe everyone is familiar with it. Is the primary key for the primary data row of a field, such as the following table
Table 'user' (int (all-in-one),key (user_id));
USER_ID as a single-field primary key, stating that no user's user_id is the same, a user_id that identifies a user.
Multi-field Federated primary key
Look at this table again
create table ' user "(username varchar (24 ), password char (32 Span style= "COLOR: #0000ff" >varchar (40 ", primary key " Span style= "COLOR: #000000" > (Username,email));
Here Username,email is used as the Federated primary Key, in order to identify a user, only the username and email are present together, and can not be identified at the same time.
Example
usernamepasswordemail zhangsan111111 [email protected]zhangsan111111 [email protected] lisi 111111 [email protected]
These three records are legal records, and the core of a multi-field federated primary key is (all fields can uniquely determine a record, like the username,email above).
MySQL Federated primary Key