I have a notes app where a user creates notes and they get synced to a database with column noteId
, which is an auto_incrementing
field. The problem is that it gets a little complicated when the user creates a not when not connected to the internet, so I have to assign a temporary noteId
, and do a bunch of other stuff related to the hierarchy of the note system structure.
So I'm thinking of dropping the auto_increment
option all together and having the local device (iPhone/iPad - Objective C) create a unique ID (possibly a timestamp) that could be used in the database as the noteId. This way if the user is offline and reconnects at a later time, syncing would be as easy as sending the unique ID.
Two questions:
- How does this affect performance? Let's say I have 500,000 notes in the database, and the user makes a change to one of his notes. With the auto_incrementing field I imagine it would be easier for the system to locate a noteId of 256,000, but with a general noteId system, would finding a noteId of 88689034 be a much lengthier process?
- What are good possibilities for generating a unique ID for a note locally on the user's device? Time stamp?