search

Home  >  Q&A  >  body text

php - Synchronize data between two tables

Table A and Table B (Table B wants to synchronize the data in Table A. The account field in Table A is the same as the account field in Table B. The condition for synchronization is that the account field exists in Table A but not in Table B. time, you need to take out the account field in table A and write it to table B synchronously) Please share a good solution for the situation where the amount of data is large and growing

天蓬老师天蓬老师2703 days ago857

reply all(1)I'll reply

  • 扔个三星炸死你

    扔个三星炸死你2017-07-03 11:42:18

    1. Option 1: When there is an operation of writing to table A, the writing operation of table B is also performed immediately.

    add(data){
        insertA(data);
        insertB(data);
    }

    2. Option 2: When there is an operation to write to table A, write the record to the queue and write it to table B asynchronously.

    add(data){
        insertA(data);
        synQueue2B(data);
    }

    In addition, both solutions can write another job to regularly compare the set of account fields in tables A and B for data synchronization

    reply
    0
  • Cancelreply