The game has some table's primary key is the self-increment ID, this part of the table merge what good scheme?

Source: Internet
Author: User
Plan to use a PHP script to complete the function, the current data backup, filtering and player ID update has been completed, that is, when the data import, some tables of the primary key is the self-increment ID, there is no thought of a particularly good plan. Please give me some expert advice, how can be a good compatibility to solve this problem?

Reply content:

Plan to use a PHP script to complete the function, the current data backup, filtering and player ID update has been completed, that is, when the data import, some tables of the primary key is the self-increment ID, there is no thought of a particularly good plan. Please give me some expert advice, how can be a good compatibility to solve this problem?

Since rendezvous once, meet the second time, it is recommended to change into a UUID directly in place, convenient for later to fit

First write a [table, ID, server]=>[uuid] conversion, and then the original table all follow the UUID re-write again, and then let the production environment originally wrote a copy of the two copies (old table and UUID new table), and then slowly read to switch to the new table, The last old table can be lost only if it is written and not read. At this point, no matter how the uniform is silky smooth, no risk.

Once helped the big brother of the curtain, met the same problem. Our solution is to write a small program to select out first, then insert in.

The maximum self-increment ID of a suit is 100, which adds 100 to all the self-increment IDs of B-suits.

I have not practiced, where I have seen such a scheme before, visual inspection is feasible, the actual situation is not very clear.

For informational purposes only.

The simplest scenario is to prefix the large region ID.
Or, with the ID of the physical server as the prefix, the ID of each database must be different.
Another option is to break the player data from different servers into different tables (albeit in a database) based on the server's table, but the data will not conflict, although it is cumbersome to manage.

Do not use the self-increment numeric ID as the primary key, use the UUID directly as the primary key. Whether you are in a uniform or distributed, it is the simplest way.

  • Related Article

    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.