DB sync between 2 devices in (almost) realtime?

Discussion in 'Chit Chat' started by Cableguy, May 13, 2015.

  1. Cableguy

    Cableguy Expert Licensed User

    Hi guys.. I've had an idea for an app, but there is something that surpasses me... I would like to implement a (almost) realtime DB sync between 2 devices and only 2 devices... Something like a master/slave relation...How could I manage this?
    Can G+ or Dropbox be used in such a way? What would be an alternative?
  2. KMatle

    KMatle Expert Licensed User

    How are these devices connected with? Do you have a webserver? PHP perhaps? Mail would do, too. Important: Database design.
  3. Cableguy

    Cableguy Expert Licensed User

    I better give you a real case scenario.

    I'm planning a joined expenses tracker. By joined I'm refering to a Husband/Wife thing.
    I Have two main possible scenarios for the device relationships...
    1 - Have a "Master" device, where the real DB would be installed, and a "slave" one who would then just manage records without actually holding the DB. This would be my ideal one, but I recon it's the least possible one.
    2 - Have a relay service, and host the DB... this would equalize the relation between the devices as they would act as clients to the DB service... This is my 2nd best case, wich would force me to buy a good host service for the DB part.

    what would be my best bet?
  4. KMatle

    KMatle Expert Licensed User

    I would use a hosted SQL database. Via httputils and a bit of php you have full control of it. It is accessable from anywhere and a save solution (imagine the master device breaks or gets lost). With the database you have ONE location for the data and it is always "synced". With a user-table you can define who is master and who is slave and a simple login function. It's simple and reliable.

    I pay about 10$/m for a unlimited hosting plan (php, MySql, unlimited db's, traffic and space). For sure there are cheaper solutions (with one or two db's).