Synchronizing one or more databases with a master database - Foreign keys

Posted by Ikke on Stack Overflow See other posts from Stack Overflow or by Ikke
Published on 2010-03-03T14:41:27Z Indexed on 2010/03/12 22:47 UTC
Read the original article Hit count: 255

I'm using Google Gears to be able to use an application offline (I know Gears is deprecated). The problem I am facing is the synchronization with the database on the server.

The specific problem is the primary keys or more exactly, the foreign keys. When sending the information to the server, I could easily ignore the primary keys, and generate new ones. But then how would I know what the relations are.

I had one sollution in mind, bet the I would need to save all the pk for every client. What is the best way to synchronize multiple client with one server db.

Edit:
I've been thinking about it, and I guess seqential primary keys are not the best solution, but what other possibilities are there? Time based doesn't seem right because of collisions which could happen.

A GUID comes to mind, is that an option? It looks like generating a GUID in javascript is not that easy.

I can do something with natural keys or composite keys. As I'm thinking about it, that looks like the best solution. Can I expect any problems with that?

© Stack Overflow or respective owner

Related posts about google-gears

Related posts about database