MySQL Federated primary Key

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.