DB_RECNUM used for "auto-incrementing" style field -
08-21-2006
, 11:02 PM
I'm interested in accessing records in a bdb using an integer-based
index. I can either:
1) Utilize bdb's DB_RECNUM flag available via Db::set_flags to uniquely
address records
-or-
2) Maintain an integer field as the key and track the maximum value per
table to implement an relational db style auto-incrementing field
#1 seems like the likely candidate, however, I see options like the
flag DB_RENUMBER which could completely dissolve any relationships
based on a "foreign-key" reference to that field.
My questions are:
1) Is it safe/advisable to use the RECNUM like a primary key? (ie.
storing this number in other db's data segments)
2) Are there any standard bdb operations (ie. compact, dump, load,
etc.) which would loose or disrupt a db's record numbers and make db
relationships inconsistant?
3) What is the upper limit on record numbering per db (~ 32-bit
integer?) and is there a well-documented/known technique for recycling
RECNUMs that have been removed (/archived)?
It may be assumed that records in these dbs will go thru the standard
insert, update, and delete operations. It is fine to have gaps in the
sequence, but it must be possible (and efficient) to maintain
consistancy across "child" dbs by propagating any RECNUM changes to
linking fields.
Thanx,
-Tomas |