Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9272997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:59:52+00:00 2026-06-18T15:59:52+00:00

My question : How can i sync 2 mysql databases (offline local database with

  • 0

My question :

How can i sync 2 mysql databases (offline local database with master online database) ?

problem is database is relational,and id as always is auto incremenate, so if i just sync using insert it will mess with my referals.

this for a clinic management app i made, problem is currently its on
server but sometimes internet connection goes down/slow on my users
clinic, so i need to let him work on offline mode (store every thing
to local db) and manually sync (bi-directional) with remote database
at end of day.
so basically each clinic should have its own local db and let them all sync to central db

example of tables.

db.Cental.users

|id|user|clinic  |
|01|demo|day care|
|02|nurs|er      |
|03|demX|day care|

db.day care.users

|id|user|clinic  |
|01|demo|day care|
|02|demX|day care|

(note id doesnt necessarily match between central and local db, yet structure of db on both is identical)

example:
my main database is more complex than this one, but that should do as an example

database info:

  1. each user have many visits,plugins.

  2. each visit contain 1user as patient_id, and 1user as doctor_id

  3. each plugin have one user, many inputs

  4. plugin_inputs have one plugin

i have 2 databases 1 on the server and other hosted locally -for offline mode-

what i want is to be able to sync locally db with online one, but since i have more than 1 user, more than one local db so each one will have nearly same id’s while online db should contain all of them combined.

so how can i sync them together ?

i user php/mysql(online)/sqlite(local)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T15:59:53+00:00Added an answer on June 18, 2026 at 3:59 pm

    There are a couple of things you can do.

    Firstly, you could consider a composite primary key for the user table – for instance, you could include “Clinic” in the primary key. That way, you know that even if the auto increment values overlap, you can always uniquely identify the user.

    The “visit” table then needs to include patient_clinic and doctor_clinic in the foreign keys.

    Alternatively – and far dirtier – you can simply set the auto increment fields for each clinic to start at different numbers: ALTER TABLE user AUTO_INCREMENT = 10000; will set the first auto_increment for the user table to 10000; if the next clinic sets it at 20000 (or whatever), you can avoid overlaps (until you exceed that magic number, which is why it’s dirty).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My question is: How can a make my Web app to store local data
Question Can I style just a part of a single character? Meaning CSS attributes
Short Question: Can I specify wildcards for custom console folding? If so, what is
My question can be boiled down to, where does the string returned from stringstream.str().c_str()
Short question: Can anyone tell me what the requirements (especially when it comes to
My original question can be found here , for which I've gotten some great
I know this question can be answered by searching in google. But I have
Right bit of a simple question can I input nText into a pivot table?
I apologize before hand if this is an obvious question: can Apache 2.0 +
I asked a question about different testing frameworks yesterday. This question can be found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.