What is the best way to have a distributed, not-always-connected database across multiple clients and a server environment?
I am building a multi-tenant web app, that also has a detached Windows client. Entities in the system include contacts, tasks, activities, etc. A lot of these entities are created at the client end, while it is disconnected from the server. A client may never connect to the server if it operates in standalone mode (which is the current version).
Now I want to make sure that when an entity is created at the client, it does not create a conflict at the server end. This appears to be a perfect job for using GUIDs as primary keys, and while it is not a problem at the client end where the number of entities may be small, I am concerned that it will potentially be an issue at the server end where the random nature of the GUIDs will make lookups very inefficient.
Additionally, at what point (ie which table) do you no longer need to use GUIDs at primary keys - for example say a task has a series of notes (1:N) - there's nothing specifically special about notes, they just need to be accessible - is there an efficient way of keying these sorts of entities?