Hi,
Quote:
Hi, I just want to ask, in Berkeley DB, if I set up a primary db, and a
secondary db based on that primary db, can this primary db support
duplicated key?
Another word, if I have a database support duplicated key, Can I add
another index db on this db? |
Not directly, no -- secondary indices use the key from the primary as
the means of associating secondary keys with records in the primary.
So the primary cannot be configured for duplicates.
If you want to achieve something like this, you will need to have some
kind of unique ID as the key in the primary database (say, a record
number), then create *two* secondary indices: one for what you are now
thinking of as the primary key (as a secondary index, it can certainly
contain duplicates), and one for the other secondary key.
See:
http://www.sleepycat.com/docs/ref/am/second.html
for more information.
Regards,
Michael.