> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of Bob Withers
> Sent: Wednesday, August 20, 2003 9:10 AM
> To: Palm Developer Forum
> Subject: RE: Faking relational databases with PDBs
>
>
> At 08:43 AM 8/20/2003 -0700, you wrote:
>
> >2) DataMgr automatically handles assigning the UIDs. I first toyed
> >with the idea of manually assigning sequential primary keys
> to each new
> >record as follows: Store the next-unassigned Primary Key
> value in the
> >DB's AppInfo block, use this as the primary key of the next-inserted
> >record and then increment. This became problematic because a) the
> >numeric value would eventually experience a wrap-around when
> it reached
> >the maximum allowable value for its data type (UInt32), and
> b) after a
> >wrap-around, how do you prevent assigning the same ID to two
> records?
> >It seemed that Palm's UID system had already figured all of this out.
>
> I've encountered problems with this approach in that if a PDB
> is beamed to
> another device the unique IDs can, and probably will, change.
> As a result
> all your references will be broken.
Bob, I didn't consider this, but this is surprising to me. Great
lengths are used to preserve the existing DataMgr-assigned Unique IDs,
as explained in this article:
http://tinyurl.com/kmbm
Just out of curiousity, do you beam a record at a time? Or do you use
ExgDBWrite() to dump the whole PDB over? It sounds like the receiving
Palm is getting a record, allocating a new one (and thus a new UID), and
then copying the contents. I would have to crack open the OS source
code to tell for sure. From my understanding of UIDs, though, I would
consider even this an OS bug. Existing UIDs should always be
preserved...
> What I've had to do to
> work around
> this is store the unique ID as a field in the data record. I
> then provide
> a function that the user can instruct the program to "resync
> the databases"
> which basically steps through each record and sets the unique
> ID from the
> value stored in the record.
Ugh.
> I also don't believe that the Palm code guarantees that
> unique ID won't be
> duplicated.
True, but it's pretty unlikely.
> Also if you generated your own unique ID based on a UInt32
> value in appInfo
> you'd have to ad over 4 billion records to the database
> before the number
> wrapped. It might take a while.
True again, but leveraging the build-in UID system of the DataMgr
prevents me from having to think about how to deal with preserving UIDs
during a HotSync restore, etc.
-Jeff Ishaq
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/